Skip to content

Instantly share code, notes, and snippets.

node_child_process.cc
16:extern char **environ;
229: // Save environ in the case that we get it clobbered
231: char **save_our_env = environ;
268: environ = env;
277: // Restore environment.
278: environ = save_our_env;
node.js
63: // Set the environ variable NODE_MODULE_CONTEXT=1 to make node load all
template <class TFunc>
auto map(const TFunc &f) -> FList<decltype(f(_Ty()))>*
{
auto temp = new FList<decltype(f(_Ty()))>();
for (auto i = begin(); i != end(); i++)
temp->push_back(f(*i));
return temp;
}
#include <iostream>
template <typename TList, typename TFunc>
void forEach(const TList& list, const TFunc& fn) {
for (auto it = list.begin(); it != list.end(); ++it)
fn(*it);
}
int main()
{
int main(int argc, const char *argv[])
{
if (argc != 2) {
printf("Usage: xml_test <filename>\n");
return 1;
}
{
#IfWinActive SmoothDraw
1::SelectColor(0)
2::SelectColor(1)
3::SelectColor(2)
4::SelectColor(3)
5::SelectColor(4)
6::SelectColor(5)
rInt :: String -> Int
rInt = read
count :: String -> Int
count [] = 1
count (a:[]) = 1
count (a:b:c) = count (b:c) + twice
where
twice = if isValid (a:b:[]) then count c else 0
isValid s = (rInt s) < 27
import Data.List
import Data.Maybe
type Point = (Int, Int)
data Line = Line Point Point
deriving (Eq, Show, Ord)
fx (Line (n, _) _) = n
fy (Line (_, n) _) = n
@jb55
jb55 / gist:716279
Created November 26, 2010 04:19
The Clay compiler is impressive
main() {
var a = map(Char, [78, 111, 119, 32, 72, 105, 113, 105, 110, 103, 0]);
println(Type(a));
println(a);
}
> Array[Char, 11]
> Now Hiring
@jb55
jb55 / fact.clay
Created November 27, 2010 06:30
Static factorial in clay
procedure fact;
overload fact(static 0) = 1;
[n | n > 0]
overload fact(static n) = fact(static n - 1) * n;
main() {
var x = fact(static 4); // == 24, calculated at compile time
}
###############################
gcd(a, b) = if (b == 0) a else gcd(b, a % b);
----------------------------------^
main() {
###############################
rational.clay(2,34): error: type propagation failed due to recursion without base case
compilation context: