Skip to content

Instantly share code, notes, and snippets.

@desbo
desbo / scan.js
Last active February 4, 2020 17:13
javascript scan function
function scan(xs, f, acc) {
var result = [];
for (var i = 0; i < xs.length; i++) {
acc = result[result.push(f(acc, xs[i])) - 1];
}
return result;
}
@desbo
desbo / demo.xml
Created June 3, 2015 15:55
demo for nat
<Book>
<Title>Sherlock Holmes</Title>
<Author>Arthur Conan Doyle</Author>
</Book>
package main
import (
"code.google.com/p/go-tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@desbo
desbo / express-status.sh
Last active August 29, 2015 14:04
Fix deprecation warnings when using res.json(status, response) in Express 4.7.0 https://github.com/strongloop/express/blob/master/History.md#470--2014-07-25
find . -type f -exec sed -i -r -e 's/(jsonp?|send)\(([0-9]+)\,\ /status\(\2\)\.\1(/g' {} \;
@desbo
desbo / image.php
Last active August 29, 2015 13:56
bad photos of phil hill script
<?php
class DogImage {
public $filename;
public $gdImage;
public $mimeType;
public $targetWidth = 960;
public $allowedTypes = array(
1, // [] gif
2, // [] jpg