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
type Connection = object | |
userName: string | |
messageHistory: list[string] | |
type ConnectionManager = object | |
networkConnections: map[string, Connection] | |
const | |
NULL_CONNECTION : Connection = ... |
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
macro foo(s: stmt) = | |
result = ast: | |
echo [. s[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
x = xml :: | |
<item> | |
<field> | |
</field> | |
</item> | |
scanner = ragel :: | |
action dgt { printf("DGT: %c\n", fc); } | |
action dec { printf("DEC: .\n"); } | |
action exp { printf("EXP: %c\n", fc); } |
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
#!/bin/bash | |
sudo apt-get install curl git-core lsb-release | |
bash < <( curl -sL https://raw.github.com/sometimesfood/chef-admin-essentials/master/contrib/install-chef.sh ) | |
mkdir ~/cookbooks | |
cd ~/cookbooks | |
echo '*~' > .gitignore | |
git init | |
git add . | |
git commit -am 'Initial commit' | |
git submodule add git://github.com/sometimesfood/chef-admin-essentials.git admin-essentials |
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
#!/bin/bash | |
sudo apt-get install ruby ruby-dev libopenssl-ruby rdoc ri irb build-essential wget ssl-cert curl | |
sudo gem install chef --no-ri --no-rdoc |
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
new closure syntax: | |
do (formal args): block | |
# passing a closure as a last argument of a nkCall or nkCommand | |
command "Foo" do (args: string): | |
code | |
code | |
code | |
btn.click do (e: TClickEvent): |
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
template openFile: expr = | |
var x: File | |
type `%dummy` = object | |
f: File | |
var `%d` = `%dummy`(x) | |
proc destroy(x: `%dummy`) = | |
callAtExitCode x.f |
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
N_NIMCALL(TY77202*, Startcmd_77238)(NimStringDesc* Command_77240, NU8 Options_77243) {TY77202* Result_77244;TY45613* C_77245;TY45613* A_77247;NI I_77287;NI HEX3Atmp_77288;NI Res_77290;Result_77244 = 0;C_77245 = 0; | |
#line 80 "/Volumes/home/zahary/Projects/nim/lib/pure/osproc.nim" | |
C_77245 = nosparseCmdLine(Command_77240);A_77247 = 0; | |
#line 82 "/Volumes/home/zahary/Projects/nim/lib/pure/osproc.nim" | |
A_77247 = (TY45613*) newSeq(NTI45613, (NI64)(C_77245->Sup.len - 1));I_77287 = 0;HEX3Atmp_77288 = 0; | |
#line 83 "/Volumes/home/zahary/Projects/nim/lib/pure/osproc.nim" | |
HEX3Atmp_77288 = (NI64)(C_77245->Sup.len - 1);Res_77290 = 0; | |
#line 1154 "/Volumes/home/zahary/Projects/nim/lib/system.nim" | |
Res_77290 = 1; | |
#line 1155 "/Volumes/home/zahary/Projects/nim/lib/system.nim" |
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
# Option[T] and safe navigation: | |
# Some languages have a specialized syntax for what is usually called "safe navigation" | |
foo?.bar[10]?.baz | |
# Option[T] could be implemented as a proxy type that rewrites any operation on it | |
# as a operation applied to the stored value (if there is any) | |
# The original example then becomes: | |
Option(foo).bar[10].baz # returns Option[type(baz)] | |
# Another point to note: proxy types used in this fashion are pretty much equivalent to Haskell's monads |
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
type | |
TBar = object | |
f: int | |
TFoo = object | |
str: string | |
sq: seq[string] | |
bar: TBar | |
proc makeFoo: TFoo = |