This file contains 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 <stdio.h> | |
#include <string.h> | |
void hex2char(char *a, unsigned char *buf) | |
{ | |
int ch; | |
char tmp[2]; | |
int i, j; | |
for (i=0,j=0; i<strlen(a); i=i+2,j++) { | |
tmp[0] = a[i]; |
This file contains 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 reg [pairs] | |
(let [M (count pairs) | |
bldr (fn [acc [x y]] | |
(let [x (bigdec x) | |
y (bigdec y)] | |
(merge-with | |
+ acc | |
{:∑x x | |
:∑y y | |
:∑xy (* x y) |
This file contains 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
#!/bin/zsh | |
prog=$0 | |
die() { | |
if [[ ! -z $1 ]]; then | |
print $1 | |
fi | |
exit 1 | |
} |
This file contains 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
#!/usr/bin/env gawk | |
# By Steve Huwig | |
# http://stackoverflow.com/questions/692312/randomly-pick-lines-from-a-file-without-slurping-it-with-unix | |
# Usage: gawk -f headrand.awk -v n=NNNN <file | |
# Waterman's Algorithm R for random sampling | |
# by way of Knuth's The Art of Computer Programming, volume 2 |
This file contains 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
import System.Environment | |
import Data.List | |
splitN :: Int -> [a] -> [[a]] | |
splitN n [] = [] | |
splitN n xs = | |
[y] ++ (splitN n ys) | |
where (y, ys) = splitAt n xs | |
main = do |
This file contains 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
#!/bin/zsh | |
# | |
# Building Emacs/Gnus/ERC apps on OS X 10.6 Snow Leopard. | |
# | |
# Need git mirror of emacs: git clone git://git.savannah.gnu.org/emacs.git | |
# And deps in MacPorts. | |
# | |
VERSION=$(git log --pretty=format:"%ai %h" -1 | perl -p -e 's,(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d) [^ ]+ ([a-z0-9]+),\1\2\3-\4\5\6-\7,') | |
###VERSION=$(bzr log -l 1 | grep revno | awk '{print $2}') |
This file contains 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
IF=wlan0 | |
ESPORT=9200 | |
echo -n me: $(sudo ifconfig $IF | sed "s,.*inet addr:\([^ ]*\).*,\1,;tx;d;:x") "master: " | |
curl -s localhost:${ESPORT}/_cluster/state | \ | |
jsawk -n 'out(this.master_node, | |
this.nodes[this.master_node].name, | |
this.nodes[this.master_node].transport_address)' |
This file contains 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
curl -s -X DELETE localhost:9200/test | |
echo | |
echo mapping | |
curl -s -X PUT localhost:9200/test -d ' | |
{ | |
"mappings": { | |
"orte": { | |
"dynamic": false, | |
"properties": { | |
"ort": { |
This file contains 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
foo |
This file contains 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
http_port 3128 | |
visible_hostname betasquid | |
acl localnet src 127.0.0.1/32 | |
http_access allow localnet | |
acl vboxnet src 192.168.56.0/24 | |
http_access allow vboxnet |