This file contains hidden or 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
/* This would be slow as hell in practice | |
* because the algorithm is quadratic; the list | |
* is recomputed every time. But oh, the | |
* simplicity is refreshing. | |
* | |
* Exercise for you, gist reader: implement | |
* this same thing with Immutable.js. | |
*/ | |
function fibs([...nums], max) { |
This file contains hidden or 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
/* Demo of fibs in an imperative style | |
* Made for benchmarking against a functional | |
* style equivalent code | |
*/ | |
function fib(max) { | |
var ret = [0]; | |
var last = 0; | |
var next = 1; | |
var temp; |
This file contains hidden or 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 <stdlib.h> | |
#include "../sqlite3/sqlite3.h" | |
#include "domain.h" | |
/* okay this function is stolen; the rest are MINE */ | |
unsigned long | |
djb2Hash(unsigned char *str) | |
{ | |
unsigned long hash = 5381; | |
int c; |
This file contains hidden or 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
function serializeQuery (queryObj) { | |
return '?' + Object.keys(queryObj) | |
.reduce(function (r, q) { | |
r.push(encodeURIComponent(q) + '=' + encodeURIComponent(queryObj[q])) | |
return r | |
}, []) | |
.join('&') | |
} | |
function readQuery (queryStr_) { |
This file contains hidden or 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
select round(unix_timestamp(sysdate(3))*1000); |
This file contains hidden or 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
// Apache2.0 license | |
// Copyright (c) 2016 Zeleke Snyder | |
import { chunk } from 'lodash' | |
export const packIntoStr = function ([...bytes]) { | |
// Pack bytes into string | |
var bytesLen = bytes.length | |
var m = 4 - (bytesLen % 4) // remaining to make it fit |
This file contains hidden or 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
set autoupdategist | |
set nosmoothscroll | |
set noautofocus | |
set typelinkhints | |
let searchlimit = 30 | |
let scrollstep = 80 | |
let barposition = "bottom" | |
set linkanimations | |
set scalehints | |
set nativelinkorder |
This file contains hidden or 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
// $ clang++ -std=c++11 -O3 leftpad.cc -o leftpad | |
// $ ./leftpad | |
#include <string.h> | |
#include <stdio.h> | |
namespace leftpad { | |
enum Dirn { | |
Left = 0, | |
Right = 1, |
This file contains hidden or 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
(defn get-columns | |
[_] | |
#{"part_id" "name" "image_paths"}) | |
(defn update | |
[_ _ _] | |
"UPDATED!!") | |
(defmacro UPDATER | |
[table] |
This file contains hidden or 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 Y = f => (x => x(x))(x => f(v => x(x)(v))) | |
// example | |
let factorial = Y(fact => n => n === 1 ? 1 : n*fact(n-1)) | |
factorial(4) // => 24 |
OlderNewer