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
LazyList<int> fibonacci([](unsigned int index, LazyList<int> *obj) -> int | |
{ | |
if(index < 2) return index; | |
return (*obj)[index-1] + (*obj)[index-2]; | |
}); | |
/* Print the first 20 fibonacci numbers */ | |
for(int i = 0; i < 20; i++) | |
printf("%d ", fibonacci[i]); |
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 <functional> | |
template<typename T> | |
class LazyList | |
{ | |
public: | |
typedef std::function<T(unsigned int, LazyList<T>*)> Generator; | |
LazyList(Generator gen) | |
: m_gen(gen) | |
{ |
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
* {padding:0;margin:0;} | |
img {border:0;} | |
.clear {clear:both;font-size:5px;} | |
.left {float:left;} | |
.right {float:right;} | |
.text-right {text-align:right;} | |
.center {text-align:center;} | |
.small {font-size:.857em !important;} /* 12px */ | |
.xsmall {font-size:.786em !important;} /* 11px */ |
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
func min(a1 int, a2 int, a3 int) int { | |
min := a1 | |
if a2 < min { | |
min = a2 | |
} | |
if a3 < min { | |
min = a3 | |
} | |
return min | |
} |
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 <utility> | |
#include <vector> | |
#include <unordered_map> | |
#include <initializer_list> | |
using namespace std; | |
template<typename T> vector<T> StaticVector(initializer_list<T> list) { return list; } | |
template<typename T, typename Y> unordered_map<T, Y> StaticHashMap(initializer_list< pair<T, Y> > list) { | |
unordered_map<T, Y> ret; | |
for (auto it = list.begin(); it != list.end(); it++) |
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
Coffeescript + types + haskell = compiled language | |
========= | |
- Increments an infinite precision number, represented as a linked list with least significant digit as head | |
increment = (x: [Num]) -> | |
switch x | |
when [] then [1] | |
when (9::tail) then 0::increment(tail) | |
when (h::t) then (h+1)::t |
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
// Top hat monocle - third party module API | |
// ===== | |
// ## Module Discovery | |
// All 3rd party modules _must_ be discoverable based on a simple http resource URI | |
// i.e. | |
// GET /modules/question | |
{ | |
name: "Question Module", |
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
# Uses django-signals behind the scenes to throw the events around | |
# Also uses gevent.pywsgi.WSGIServer to stream the event source. | |
# Basic usage | |
from django.dispatch import Events | |
from django.contrib.auth.models import User, Group | |
# Basic support for individual users | |
user = User.objects.get(id=1) | |
user.subcribe('event:name another:event') # subscriptions are session persistent (configurable to db)? |
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
import nails | |
class IndexController(nails.Controller): | |
def index(self, request): | |
return "Hello World from controller!" | |
def proof(self, request): | |
return "Proof that routing is working" |
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 inspect import getfullargspec, getsourcelines | |
type_map = { | |
int: 'integer' | |
} | |
tmpl = """ | |
CREATE FUNCTION {func_name} ({args}) | |
RETURNS {return_t} | |
AS $$ |
OlderNewer