This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#putc - put one character to output (interrupt 11) | |
putc $1 addi $2,$0,11 addu $4,$0,RG1 syscall | |
#getc - get one character (interrupt 12) | |
getc $1 addi $2,$0,12 syscall add RG1, $0, $2 | |
#puts - put a string (interrupt 4) | |
puts $1 addi $2,$0,4 addu $4,$0,RG1 syscall | |
#done - end the program (interrupt 10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# send libnotify updates only for certain users. Edit the variable okAccounts to select which accounts. | |
# | |
# depends on notify-send | |
# To install, add this to your ~/.purple/plugins directory (you may have to create it) | |
# Then enable the plugin | |
use Purple; | |
# edit the keys in this hash to enable alerts for only these users | |
# the value is irrelevant | |
%okAccounts = ('User 1' => '1', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Normally, we tokenize based on white space. But there are times we want to keep words across whitespace, e.g. | |
/// "in basket" should not become "in" "basket". This class allows you to do that. | |
/// </summary> | |
class SpecialWordsTokenFilter : TokenFilter | |
{ | |
// TODO: Set position and offset attributes as well as term | |
readonly TermAttribute termAttribute; | |
readonly Dictionary<string, string> TwoWords = new Dictionary<string, string>(); | |
private Queue<string> bufferBuffer = new Queue<string>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bitstring import BitArray | |
''' | |
Returns m * r using Booth's algorithm. | |
x = len(m) and y = len(r). Note that this is the length in base 2. | |
See http://en.wikipedia.org/wiki/Booth%27s_algorithm | |
''' | |
def booth(m, r, x, y): | |
# Initialize | |
totalLength = x + y + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
$.fn.toggleAttr = function (attr, val1, val2) { | |
///<summary>Toggles an attribute between having one of two possible states</summary> | |
///<param name="attr">Attribute name</param> | |
///<param name="val1">First value</param> | |
///<param name="val2">Second value</param> | |
return this.each(function () { | |
var $this = $(this); | |
if ($this.attr(attr) === val1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Y combinator. Note that this doesn't actually compile in Haskell, but it's simpler | |
-- than the one which works | |
Y f = (\x -> f (x x)) (\x -> f (x x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- An example of how the Y combinator expands into an infinite | |
-- list of function applications | |
Y f = (\x -> f (x x)) (\x -> f (x x)) | |
= f $ (\x -> f (x x)) (\x -> f $ x x) | |
= f $ f $ (\x -> f $ x x) (\x -> f $ x x) | |
= f $ f $ f $ (\x -> f $ x x) (\x -> f $ x x) | |
= f $ f $ f $ f $ (\x -> f $ x x) (\x -> f $ x x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Mu is just a wrapper since we can't create infinitely recursive type | |
-- signatures for functions, but we can create recursive ADTs. | |
-- You can glean the point of Mu from the type signature of actualFn | |
data Mu a = Mu { actualFn :: [Mu a] -> a -> a } | |
-- | Factorial function | |
fact :: Num a => [Mu a] -- ^ An infinite list of factorial functions | |
-> a -- ^ The number to find the factorial of | |
-> a | |
fact (f:fs) n = if n == 1 then 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fact genFact n = if n == 1 then 1 | |
else n * ( | |
if (n-1) == 1 then 1 | |
else (n-1) * ( | |
if (n-2) == 1 then 1 | |
else (n-2) * ( | |
if (n-3) == 1 then 1 | |
else (n-3) * ( | |
... | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Normally, we tokenize based on white space. But there are times we want to keep words across whitespace, e.g. | |
/// "in basket" should not become "in" "basket". This class allows you to do that. | |
/// </summary> | |
class SpecialWordsTokenFilter : TokenFilter | |
{ | |
readonly TermAttribute termAttribute; | |
readonly Dictionary<string, string> TwoWords = new Dictionary<string, string>(); | |
private Queue<string> bufferBuffer = new Queue<string>(); | |
OlderNewer