Skip to content

Instantly share code, notes, and snippets.

View hkjels's full-sized avatar

Henrik Kjerringvåg hkjels

View GitHub Profile
@hkjels
hkjels / fredag
Created October 15, 2010 13:21
Just a funny page for work. Makes it easier to choose the lunch special
<?php
$date = strtotime('today');
if (date('D', $date) == 'Fri') {
$sentences = array(
'en fest med',
'i dag blir det',
'konge!! ',
'Can you dig it! ',
'På menyen i dag har vi',
'Ikke no kebab her nei!'
/**
*/
config = require('yaml').eval(
require('fs')
.readFileSync(process.env['HOME'] + '/.clickatell.yml')
.toString('utf-8')
);
var clickatell = require("../lib/clickatell.js");
clickatell = new clickatell(config)
@hkjels
hkjels / gist:1009526
Created June 5, 2011 23:09
Modifying json
// When I send "req.body", the entire object is sent correctly
"data" : req.body // {'key':value, 'key':value}
// However, if I prepend the key "settings". Only the key is passed a long with a blank string
"data" : { "settings" : req.body } // { 'settings' : '' }
// Same result if I build the object separately
data = {}
data["settings"] = req.body
"data" : data // { 'settings' : '' }
@hkjels
hkjels / index.js
Created November 26, 2011 16:06
Locals have session-like behavior
/*!
* Routes
*/
app.param('title', routes.precondition)
app.get('/', routes.tasks)
app.get('/task/:title', routes.task)
@hkjels
hkjels / git-svn.sh
Created May 25, 2012 06:43
git-svn helper
# git-svn
s() {
git_aliases=($(git config --get-regexp alias | sed -e s/alias\.//g))
IFS='
'
# Expand git aliases
for cmd in $git_aliases; do
g_cmd=$(echo $cmd | cut -d " " -f2-)
g_alias=$(echo $cmd | awk {'print $1'})
@hkjels
hkjels / gist:2890962
Created June 7, 2012 19:14
Codestyle
// req.cookies might not be set, so how do I solve this nicely?
var language = req.query.language || req.cookies.language
// Is it really necessary to do the whole
if (typeof req.cookies !== 'undefined')
// routine?
@hkjels
hkjels / gist:3076042
Created July 9, 2012 11:54
Pluck from object
pkg = require './package'
meta = for key, val of pkg
if key in ['name', 'author', 'keywords', 'description']
{key: val}
@hkjels
hkjels / gist:4112125
Created November 19, 2012 17:34
shopt -s progcomp
# {{{
# Node Completion - Auto-generated, do not touch.
shopt -s progcomp
for f in $(command ls ~/.node-completion); do
f="$HOME/.node-completion/$f"
test -f "$f" && . "$f"
done
# }}}
@hkjels
hkjels / gist:5090203
Created March 5, 2013 13:09
Verbose homebrew output
==> Downloading http://www.apache.org/dyn/closer.cgi?path=/couchdb/1.2.1/apache-couchdb-1.2.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/couchdb-1.2.1.tar.gz
/usr/bin/tar xf /Library/Caches/Homebrew/couchdb-1.2.1.tar.gz
==> ./configure --prefix=/usr/local/Cellar/couchdb/1.2.1 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc --with-erlang=/usr/local/lib/erlang/usr/include --with-js-include=/usr/local/include/js --with-js-lib=/usr/local/lib
./configure --prefix=/usr/local/Cellar/couchdb/1.2.1 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc --with-erlang=/usr/local/lib/erlang/usr/include --with-js-include=/usr/local/include/js --with-js-lib=/usr/local/lib
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
@hkjels
hkjels / config.log
Created March 5, 2013 13:10
couch config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by Apache CouchDB configure 1.2.1, which was
generated by GNU Autoconf 2.67. Invocation command line was
$ ./configure --prefix=/usr/local/Cellar/couchdb/1.2.1 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc --with-erlang=/usr/local/lib/erlang/usr/include --with-js-include=/usr/local/include/js --with-js-lib=/usr/local/lib
## --------- ##
## Platform. ##