Skip to content

Instantly share code, notes, and snippets.

Arian Stolwijk arian

Block or report user

Report or block arian

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@arian
arian / index.js
Created Oct 9, 2015
requirebin sketch
View index.js
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var slick = require('slick');
var sMyString = "<foo><bar></bar></foo>";
var oParser = new DOMParser();
var oDOM = oParser.parseFromString(sMyString, "text/xml");
console.log(slick('bar', oDOM));
@arian
arian / svn
Last active Jan 18, 2016
svn tools
View svn
#!/bin/sh
usage () {
cat <<USAGE
Helper commands:
tags - List all tags relevant to this trunk
branches - List all branches relevant to this trunk
tag - Tag a trunk or branch copy.
branch - Branch a trunk or tag working copy.
@arian
arian / church.js
Last active Sep 20, 2016
Church Numerals, Booleans, Pairs and Lists in JavaScript (ES6)
View church.js
// conversions
let c2i = x => x(y => y + 1, 0)
let c2star = x => x(y => y + '*', '')
let c2b = x => x('True', 'False')
let c2a = xs => xs((y, ys) => [c2i(y)].concat(ys), [])
// numbers
let zero = (s,z) => z
let one = (s,z) => s(z)
View quicksort.go
package main
import "fmt"
func quicksort(list []int) []int {
l := len(list)
if (l <= 1) {
return list
}
@arian
arian / fun.js
Last active Aug 28, 2016
Functional JS
View fun.js
"use strict";
function toArray(thing) {
if (Array.isArray(thing)) return thing;
return Array.prototype.slice.call(thing);
}
function head(arr) {
return arr[0];
}
View functional.js
var filter = require('prime/array/filter');
var slice = Array.prototype.slice;
var curry = function(fn){
var args = slice.call(arguments, 1);
return function(self){
fn.apply(null, [self].concat(args);
};
};
View prime-amd-one-file.js
(function () {
var modules = {}, cache = {};
if (typeof define == 'undefined') {
window.define = function (id, factory) {
modules[id] = factory;
};
window.require = function (id) {
var module = cache[id];
if (!module) {
module = cache[id] = {};
@arian
arian / build.sh
Created Apr 1, 2013
Using Prime in gjs to create Gtk Applications.
View build.sh
# use the split-generics branch of prime.
wrup -r prime ../../www/prime/index.js -r bind ../../www/prime/function/bind -o prime.js
@arian
arian / multiply.js
Last active Dec 14, 2015
How Hardware multiplies unsigned integers
View multiply.js
function multiply(multiplicant, multiplier){
var product = 0;
for (var i = 0; i < 32; i++){
product += (multiplier & 1) ? multiplicant : 0;
multiplicant <<= 1;
multiplier >>= 1;
}
@arian
arian / selection-sort.asm
Created Feb 27, 2013
Selection Sort in MIPS assembly, for, I don't know, your PSP?
View selection-sort.asm
.text
j main # Jump to main-routine
.data
str1: .asciiz "Insert the array size \n"
str2: .asciiz "Insert the array elements,one per line \n"
str3: .asciiz "The sorted array is : \n"
str5: .asciiz "\n"
.text
You can’t perform that action at this time.