View generator.zig
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
const std = @import("std"); | |
const debug = std.debug; | |
const builtin = @import("builtin"); | |
const TypeInfo = builtin.TypeInfo; | |
const TypeId = builtin.TypeId; | |
/// Iterator based on async functions. Equivalent to generators in Python, | |
/// Javascript, etc. | |
/// |
View closure.zig
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
const std = @import("std"); | |
const assert = std.debug.assert; | |
pub fn closure(bindings: var) ClosureInternal(@TypeOf(bindings)) { | |
return ClosureInternal(@TypeOf(bindings)) { .ctx = bindings }; | |
} | |
fn ClosureInternal(comptime Spec: type) type { | |
comptime { | |
const spec_tinfo = @typeInfo(Spec); |
View kak.inc.sh
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
kakquote() { | |
out= | |
for text; do | |
out=$out"'" | |
while :; do | |
case "$text" in | |
*\'*) | |
out=$out${text%%\'*}\'\' | |
text=${text#*\'} | |
;; |
View example.sh
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/sh | |
source parse_args.inc.sh | |
arg_alias() { | |
case "$1" in | |
h) printf help;; | |
m) printf monitor;; | |
w) printf wait;; | |
r) printf rate; false;; |
View async_generators.zig
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
const std = @import("std"); | |
const expectEqual = std.testing.expectEqual; | |
const expect = std.testing.expect; | |
const tuples = @import("tuples.zig"); | |
const Tuple = tuples.Tuple; | |
const tuple = tuples.tuple; | |
const comptime_utils = @import("comptime_utils.zig"); |
View comptime_utils.zig
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
const std = @import("std"); | |
const bufFmt = std.fmt.bufPrint; | |
pub fn compileErrorFmt(comptime fmt: []const u8, comptime args: var) void { | |
comptime { | |
var buf: [4096]u8 = undefined; | |
@compileError(@as([]const u8, bufFmt(&buf, fmt, args) catch |_| { | |
@compileError("compileFmt: output is too long. Cannot output @compileLogs longer than 4096 bytes"); | |
})); | |
} |
View rpn.js
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 node | |
var input = require("fs").readFileSync( | |
require("path").join(process.cwd(), process.argv[process.argv.length - 1]), | |
"utf8" | |
); | |
var gvars = {}; | |
function exec(input, fns, vars) { | |
(function findStrs() { | |
var inStr = false; |
View gist:1905351
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
tco = (fn) -> (args...) -> | |
if @recured? or @args? or @recur? | |
unless arguments.callee.noWarn | |
# here we are taking precautionary measures to make sure we don't | |
# accidentally overwrite some important properties in the context named | |
# "recured", "args" or "recur". The warnings can be disabled by setting | |
# the `noWarn` property of the function to true | |
throw new Error """ | |
calling a tail-recursive function in this context will overwrite the | |
properties "recured", "args" and "recur". |
View petri.py
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
from random import * | |
# from colors import * | |
import os | |
import math | |
import sys | |
import time | |
def gen_row(min, max): | |
return [randint(min, max) if random() <= 0.4 else 0 for i in range(0, 50)] |
View command.js
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 Kaffeine = require("./../lib/index"), | |
fs = require('fs'), | |
path = require('path'), | |
optparse = require('optparse'), | |
util = require("util"), | |
sources = [], | |
options = {}, | |
oparser |
NewerOlder