Skip to content

Instantly share code, notes, and snippets.

@arian
arian / crop.js
Created August 5, 2012 19:33
Cropping images with nodejs streams and imagemagick
var spawn = require('child_process').spawn;
var Stream = require('stream');
/**
* crops and resizes images to our desired size
* @param {Stream} streamIn in stream containing the raw image
* @return {Stream}
*/
exports.cropImage = function(streamIn){
@-webkit-keyframes rotate {
0% {-webkit-transform: rotate(0deg);}
100% {-webkit-transform: rotate(360deg);}
}
.rotation {
-webkit-animation: rotate;
-webkit-animation-duration: 1s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
@arian
arian / church.js
Last active September 12, 2021 21:42
Church Numerals, Booleans, Pairs and Lists in JavaScript (ES6)
// 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)
#! /usr/bin/env bash
# build MooTools
packager build Core/Class \
Core/Class.Extras \
Core/Element \
Core/Element.Event \
Core/DOMReady \
-blocks 1.2compat 1.3compat '!ES5' '!ES5-bind' \
@arian
arian / Camel.matlab
Created May 19, 2011 11:06
Camel and Bananas Puzzle
%% puzzle description
%
% There is a desert, one camel and 3000 bananas.
%
% The camel has to transport as many bananas 1 km (1000 m).
% However each meter, the camel eats one banana.
% Also the camel can only carry 1000 bananas at the same time
%
% What is the maximum number of bananas the camel can bring to the other side?
%
@arian
arian / selection-sort.asm
Created February 27, 2013 16:35
Selection Sort in MIPS assembly, for, I don't know, your PSP?
.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
@arian
arian / collegedownloader.sh
Last active June 5, 2017 21:05
Download TU Delft Collegerama video streams, Silverlight player sucks.
#!/bin/bash
slides=1;
video=1;
for var in "$@"
do
if [ "${var}" = "--slidesOnly" ]; then
video=0;
@arian
arian / fun.js
Last active August 28, 2016 05:31
Functional JS
"use strict";
function toArray(thing) {
if (Array.isArray(thing)) return thing;
return Array.prototype.slice.call(thing);
}
function head(arr) {
return arr[0];
}
@arian
arian / svn
Last active January 18, 2016 15:44
svn tools
#!/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.
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);
};
};