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 somePointerMod | |
let cptr = somePointer () | |
cptr.printPointer |
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
#!/usr/bin/env python3 | |
from gi.repository import Gtk, GObject | |
import signal, sys, os | |
count = {} | |
def signal_handler (signal, frame): | |
print('Signal %d trapped!' % signal) |
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
proc cgenTrace (skip:int = 0, drop:int = 16):string = | |
var a = "" | |
var b = getStackTrace () | |
while a != b: | |
a = b | |
b = replace (a, " ", " ") | |
let c = split (a, "\n") | |
let e = c.len-(3+skip) | |
let g = 1+drop; | |
if (e < 1) or (g > e): |
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
See https://github.com/Araq/Nimrod/issues/1137 (nimecho0 and nimecho1 echo strings with embedded nuls) | |
$ nimrod c -x:off --opt:speed --deadCodeElim:on --stackTrace:off --lineTrace:off nimecho.nim | |
$ ./nimecho 0 > /dev/null | |
using nimecho0 | |
1.8825269999999998e+00 seconds elapsed | |
1.8825269999999999e-06 seconds per iteration | |
string used: some very long string some very long string some very long string some very long string some very long string some very long string |
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 <stdarg.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
void nimecho (int n, ...) { | |
typedef char* cptr; | |
va_list ap; | |
int i; | |
int len = 0; |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
auto const src = "This is a test. This is a test. This is a test. This is a test."; | |
ssize_t len; | |
char* dst; | |
void copy_append () { | |
memcpy (dst, src, len); |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
auto const src = "This is a test. This is a test. This is a test. This is a test."; | |
ssize_t len; | |
char* dst; | |
void copy_append () { | |
memcpy (dst, src, len); |
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 os, macros | |
macro huh (cmd1, cmd2: expr) : stmt = | |
let cs = toStrLit(callsite ()) | |
echo "entering ", cs | |
echo parseCmdLine ($cmd1) | |
var a = $cmd2 | |
echo a | |
echo "leaving ", cs, "\n" | |
discard |
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 macros | |
macro foo (first, second : expr) : stmt = | |
echo first | |
echo second | |
echo "" | |
discard | |
foo one, two |