Skip to content

Instantly share code, notes, and snippets.

View unpack.sh
unpack() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
View upgrade-postgres-9.3-to-9.4.md

TL;DR

sudo pg_dropcluster 9.4 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main

@nkt
nkt / measure.sql
Created Feb 23, 2015
Postgres function for calculating measure in meters between two points
View measure.sql
CREATE FUNCTION measure(_from POINT, _to POINT)
RETURNS DOUBLE PRECISION AS $$
DECLARE
d_lat DOUBLE PRECISION;
d_lon DOUBLE PRECISION;
_a DOUBLE PRECISION;
_c DOUBLE PRECISION;
_d DOUBLE PRECISION;
BEGIN
d_lat = (_to [0] - _from [0]) * pi() / 180;
@nkt
nkt / deploy.js
Last active Aug 29, 2015
Simple standalone deploy server written on Node.js
View deploy.js
var childProcess = require('child_process');
var http = require('http');
var util = require('util');
var path = require('path');
var fs = require('fs');
var listen = process.env.LISTEN || 8000;
var home = process.env.HOME;
var key = process.env.DEPLOY_KEY;
@nkt
nkt / dump.js
Created Feb 26, 2015
Simple function for node.js debugging
View dump.js
function dump(what, depth, colors) {
var util = require('util');
console.log(util.inspect(what, {
depth: depth || 2,
colors: colors === undefined ? true : colors
}));
}
View init-dnd.js
function initDnD(element, cb, accept = 'image/*') {
let input = document.createElement('input');
input.type = 'file';
input.accept = accept;
input.addEventListener('change', (e) => {
cb(input.files[0]);
});
element.addEventListener('click', (e) => {
e.preventDefault();
input.click();
View html.md
HTTP Working Group                         T. Berners-Lee, MIT/LCS
INTERNET-DRAFT                              R. Fielding, UC Irvine
<draft-ietf-http-v10-spec-05.html>             H. Frystyk, MIT/LCS
Expires August 19, 1996                          February 19, 1996

Hypertext Transfer Protocol -- HTTP/1.0

@nkt
nkt / rfc.css
Created Apr 4, 2015
Make rfc texts more human readable
View rfc.css
body {
font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;
font-size: 16px;
line-height: 1.6;
width: 1000px;
margin: 0 auto;
word-wrap: break-word;
}
a[href] {
@nkt
nkt / example.js
Created Apr 20, 2015
Simple slack integration in node project.
View example.js
const notifier = require('./notifier');
notifier.sendMessage('Hello world!').then((res) => {
// handle response
}).catch((e) => {
console.error(e);
});
View skype_mute.sh
#!/usr/bin/osascript
tell application "Skype"
if (send command "GET MUTE" script name "MuteToggler") is equal to "MUTE ON" then
send command "SET MUTE OFF" script name "MuteToggler"
else
send command "SET MUTE ON" script name "MuteToggler"
end if
end tell