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
#include <stdio.h> | |
// Make a NEWTYPE | |
#define NT(inner,outer) \ | |
typedef struct \ | |
{ \ | |
inner _nt_field; \ | |
} outer | |
// Declare a val of NEWTYPE |
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
module ReadBase where | |
import Numeric | |
import Maybe | |
readBase :: Integer -> String -> [(Integer,String)] | |
readBase base input = readInt base isValid toValue input | |
where chars = ['0'..'9'] ++ ['A'..'Z'] ++ ['a'..'z'] | |
vals = zip chars [0..(fromIntegral base)] | |
isValid = flip elem chars |
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
/* gcc -Wall -O3 c_sqlite_test.c -lsqlite3 -o c_sqlite */ | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <string.h> | |
#include <sqlite3.h> | |
/* Macros to simplify things. */ | |
#define BEGIN_TRANSACTION() do { int e; char em[1024]; \ |
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
-- div2.hs | |
data Nat = Zero | Succ Nat | |
deriving (Show) | |
zero = Zero | |
one = Succ zero | |
two = Succ one | |
three = Succ two | |
four = Succ three |
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
A monad is a datatype used to describe actions. Wait, what? What do you mean | |
'describe an action'?! | |
Well, at least in Haskell, we're not really using actions or statements; we're | |
using mathematical transformations. But sometimes, we really want to think of | |
something a 'doing' something to another thing. In those circumstances, due to | |
Haskell's semantics, we need a sort of mathematical description of what 'doing | |
something to something else' means. | |
The mathematical abstraction of this is a monad. |
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
class Array | |
def subdivide(len) | |
return self if len <= 0 || len >= self.size | |
from = 0 | |
result = [] | |
while from < self.size | |
result << self.slice(from, len) | |
from += len | |
end |
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
#include <stdio.h> | |
#include <string.h> | |
#include <stdint.h> | |
uint32_t THE_STATUS_REGISTER = 0; | |
typedef void (*handler) (void); | |
typedef struct { | |
handler hdl; |
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
alias orig_method_missing method_missing | |
def method_missing(sym, *args) | |
if driver.methods.include?(sym.to_s) | |
driver.send(sym, *args) | |
else | |
orig_method_missing(sym, *args) | |
end | |
end |
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
dist/build/Language/C/Parser/Lexer.hs:522:17: | |
Warning: Bindings containing unlifted types should use an outermost bang pattern: | |
(new_s) | |
= if (offset >=# 0#) && (check ==# ord_c) then | |
alexIndexInt16OffAddr alex_table offset | |
else | |
alexIndexInt16OffAddr alex_deflt s | |
In the expression: | |
let | |
(base) = alexIndexInt32OffAddr alex_base s |
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
describe "thing" do | |
before do | |
@obj_1 = Object.new | |
@obj_2 = Object.new | |
stub(@obj_1).foo { puts "stubbed foo (1)" } | |
stub(@obj_2).foo { puts "stubbed foo (2)" } | |
end | |
it "1 does things" do | |
mock(@obj_1).foo { puts "mocked foo (1)" } |
OlderNewer