Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@passcod
passcod / rarr.js
Created February 9, 2013 08:58
Reverse array sort
function rarr (n) {
var arr = [];
for (var i = n; i >= 0; i--) {
arr.push(i);
}
arr.sort();
return arr;
}
var total = 0;
@passcod
passcod / fastfib.js
Created February 9, 2013 10:08
Fastfib
function fastfib(n){
var i=0, fibs = [0,1];
for (; i < n; i += 1) {
fibs.push(fibs[0] + fibs[1]);
fibs.shift();
}
return fibs[0];
}
var n = 0, last = 0;
@passcod
passcod / merge-pr.sh
Last active December 12, 2015 09:29
Script to automate merging PRs on [homebrew-cask](https://github.com/phinze/homebrew-cask)
#!/bin/bash
if [[ -z "$1" ]]; then
echo " => Usage: $0 user:branch"
exit 64
fi
user=$(cut -d ":" -f1 <(echo "$1"))
repo="homebrew-cask"
branch=$(cut -d ":" -f2 <(echo "$1"))
@passcod
passcod / hotot.rb
Last active December 13, 2015 19:58
Homebrew formula for Hotot (twitter client) using Qt.
require 'formula'
class Hotot < Formula
homepage 'https://github.com/lyricat/Hotot'
url 'https://github.com/lyricat/Hotot/archive/0.9.8.10.tar.gz'
sha1 '09e1aae05546b99abc593df0c55d664a04336c43'
head 'https://github.com/lyricat/Hotot.git'
depends_on 'cmake' => :build
@passcod
passcod / kana.sh
Last active December 13, 2015 23:49
#!/bin/bash
# Golfed. 813 chars.
# Original: https://github.com/Qwertylex/bash-kanatrainer
# License: CC BY-SA 3.0.
l="a;i;u;e;o;ka;ki;ku;ke;ko;sa;shi;su;se;so;ta;chi;tsu;te;to;na;ni;nu;ne;no;ha;hi;fu;he;ho;ma;mi;mu;me;mo;ya;yu;yo;ra;ri;ru;re;ro;wa;wo;n"
hira="あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん"
kata="アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマモムメモヤユヨラリルレロワヲン"
read -ep "hira or kata: " c;a=$(eval echo $`echo ${c}`)
n=0;r=0;t=${#a};IFS=';' read -ra l <<< "$l"
N = 100
digits = ""
sums = []
for n in [1..N]
digits += Math.floor Math.random() * 10
for n in [0..(N-6)]
sub = digits.substr n, 5
sum = 0
@passcod
passcod / 1000.js
Last active December 14, 2015 00:38
var N = 1000,
digits = "",
sums = [],
i,l,n,sum,sub;
for (n = 1; n <= N; ++n) {
digits += Math.floor(Math.random() * 10);
}
for (n = 0; n <= (N-6); ++n) {
seq = (a, b = a) ->
if typeof a == "number" and (a == b or typeof b == "number")
if a != b
"(#{a}..#{b})"
else
"(0..#{a})"
else if typeof a != "string" or !rgx.test a or a == ""
"(0..1)"
else
[ok, start, end] = a.match rgx
[22:56:38] <Milos> what'as new
[22:56:40] <Milos> how was camp
[22:56:42] <Milos> whatcha coding
[22:56:47] <Milos> how's uni
[22:56:49] <Milos> whatcha studying
[22:56:53] <passcod> camp was sunny
[22:56:56] <unixbrain> !quotes * /.*/
[22:56:58] <woot> 2012-02-26 18:17:28 | <akiwiguy> my ups kicked in this morning
[22:57:14] <unixbrain> !quotes * /.*/
[22:57:16] <woot> 2012-01-06 16:01:47 | <spectre0> !calc (-9.551 + 0.819152a = 0.087156b + 28.98)
@passcod
passcod / gist:5202890
Last active December 15, 2015 04:39
Linode datacenters ping and data tests, from home (Rural / Whangarei, NZ) and current vps (AWS / Sydney).
Ping => (-c 10, avg ms, lower is better)
From home: tokyo:379, london:449, newark:349, atlanta:206, dallas:179, fremont:174
From sydn: tokyo:116, london:392, newark:247, atlanta:219, dallas:242, fremont:190
----
Data => (20s, avg KB/s, higher is better)
From home: tokyo:170, london:457, newark:350, atlanta:461, dallas:560, fremont:616
From sydn: tokyo:2196, london:628, newark:2308, atlanta:766, dallas:1097, fremont:1413