Skip to content

Instantly share code, notes, and snippets.

View jbe's full-sized avatar
🙊

Jostein Berre Eliassen jbe

🙊
View GitHub Profile
// Instead of
let im_session = createMockSession();
im_session = im_session.setIn(["person", "id"], personId);
// It is also possible to write
const im_session = createMockSession()
.setIn(["person", "id"], personId);
#include <stdlib.h>
#include <stdio.h>
#define RT_assert(ignored)
#define RT_die(ignored) exit(1)
int
get_next_utf_8_codepoint(const char **str)
{
@jbe
jbe / index.js
Created July 5, 2016 19:52
requirebin sketch
// Gist: https://goo.gl/23tBjT
const {
$, mount, loop, cond,
dom, h1, p, button, div
} = require("zodiac");
function Button({text, $click}) {
return button({
Tupfile:
: helloworld.c |> cl -c helloworld.c |> helloworld.obj
helloworld.c:
#include<stdio.h>
int main()
{
printf("Hello world");
return 0;
// Gist: https://goo.gl/23tBjT
const {
$, mount, loop,
dom, h1, p, button, div,
} = require("zodiac");
function Button({text, $click}) {
return button(
{ $click, type: "button" },
# The following code produces a segfault from within gc.nim (see bottom)
# The segfault does not occur when using --gc:markAndSweep
type
TNode = tuple
prev: ptr TNode
var
front = cast[ptr TNode](alloc0(sizeof(TNode)))
type
TChunkyNode[IX, T] = tuple
elms: array[IX, T]
next: PChunkyNode[IX, T]
PChunkyNode[IX, T] = ptr TChunkyNode[IX, T]
TChunkyArray*[IX, T] = object
first: PChunkyNode[IX, T]
size: int
template a(payload: stmt) =
payload
a:
a: # (a is a normal template)
a:
a:
a:
@jbe
jbe / queue_test.nim
Created August 11, 2013 23:33
This nimrod code produces a SIGSEGV
import queues
type
TWidget = object
names: TQueue[string]
var w = TWidget(names: initQueue[string]())
add(w.names, "Paddington")
@jbe
jbe / gist:2549356
Created April 29, 2012 10:55
haskell.hs
-- Functions
double n = n * 2
double_upto_hundred n = if double n > 100
then n
else double_upto_hundred (double n)