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
/* | |
So with documents as such: | |
{ | |
one_id : 1, | |
another_id : 22, | |
created_at : "2011-05-26 23:22:11", | |
a_name : "Lisa" | |
} | |
We want to get a count of the unique 'a_name' values possibly |
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
set_options(Bt, []) -> | |
Bt; | |
set_options(Bt, [{split, Extract}|Rest]) -> | |
set_options(Bt#btree{extract_kv=Extract}, Rest); | |
set_options(Bt, [{join, Assemble}|Rest]) -> | |
set_options(Bt#btree{assemble_kv=Assemble}, Rest); | |
set_options(Bt, [{less, Less}|Rest]) -> | |
set_options(Bt#btree{less=Less}, Rest); | |
set_options(Bt, [{reduce, Reduce}|Rest]) when is_function(Reduce, 2) -> | |
set_options(Bt#btree{reduce=Reduce}, Rest). |
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
var linkedChild1 = Object.create(sharedParent); | |
var linkedChild2 = Object.create(sharedParent); | |
//now you become a Panda... but it could effect everyone else making them sad | |
linkedChild1 = Panda(linkedChild1); | |
var unlinked1 = Object.create(parent.clone()); | |
var unlinked2 = Object.create(parent.clone()); | |
//now you become a Grizzly leaving everyone else behind so you can eat them |
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 Person() { | |
//public member | |
this.Name = "Copenhaver"; | |
//convention based "private" | |
this._ccn = "5555555555555"; | |
/* thought this was unusable, but it's actually scoped inside | |
* this invocation of the function and usable by other members of | |
* the object currently being built. |
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
<!-- other view/html stuff --> | |
<h3>Cell Phone<h3> | |
@Html.Phone().For(m => m.Cell) | |
<h3>Business Line<h3> | |
@Html.Phone().For(m => m.BusinessNumber) | |
.WithExtension(m => m.BusinessExtension) | |
.Render() |
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
public class PhoneHtmlBuilder<TModel> | |
{ | |
private HtmlHelper<TModel> _helper; | |
private Expression<Func<TModel, string>> _phoneNumber; | |
private Expression<Func<TModel, string>> _extension; | |
public PhoneHtmlBuilder(HtmlHelper<TModel> helper) | |
{ | |
_helper = helper; | |
} |
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
public static class HtmlHelperExtensions | |
{ | |
public static PhoneHtmlBuilder<TModel> Phone(this HtmlHelper<TModel> helper) | |
{ | |
return new PhoneHtmlBuilder<TModel>(helper); | |
} | |
//... a bunch of other things | |
} |
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
{ok, Tokens, _EndLine} = lexical:string("2 + 1 * 3"). | |
{ok, Ast} = grammar:parse(Tokens). | |
Program = generator:generate(Ast). | |
vm:start(). | |
vm:load(Program). | |
vm:stop(). | |
receive {return, Value} => Value 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
-module(generator). | |
-export([generate/1]). | |
generate([Root, Left, Right]) -> | |
LeftExp = generate(Left), | |
RightExp = generate(Right), | |
RootExp = generate(Root), | |
LeftExp ++ RightExp ++ RootExp; | |
generate({number, _Line, Value}) -> |
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
Nonterminals expression. | |
Terminals number '+' '-' '/' '*' '(' ')'. | |
Rootsymbol expression. | |
Endsymbol '$end'. | |
Left 300 '+'. | |
Left 300 '-'. | |
Left 400 '*'. | |
Left 400 '/'. |