Skip to content

Instantly share code, notes, and snippets.

View uggedal's full-sized avatar

Eivind Uggedal uggedal

View GitHub Profile
na ~/dev/states cat phantomjs/init.sls
phantomjs:
pkg.installed
phantomjs:
pkg.installed
@uggedal
uggedal / ps_mem.sh
Created May 24, 2012 09:42
Lightweight mediaqueri.es server
$ ps_mem
Private + Shared = RAM used Program
4.0 KiB + 77.0 KiB = 81.0 KiB agetty
60.0 KiB + 59.0 KiB = 119.0 KiB init
176.0 KiB + 38.0 KiB = 214.0 KiB dhcpcd
180.0 KiB + 63.5 KiB = 243.5 KiB crond
56.0 KiB + 280.5 KiB = 336.5 KiB udevd [updated] (3)
276.0 KiB + 95.0 KiB = 371.0 KiB sshd
324.0 KiB + 232.5 KiB = 556.5 KiB ntpd
@uggedal
uggedal / inotifier
Created February 18, 2012 12:33
buster.js autotest
#!/bin/sh
#
# Requires: apt-get install inotify-tools
# Usage: inotifier buster test
FORMAT="%w%f written"
"$@"
while inotifywait -qre close_write --format "$FORMAT" .; do
var page = require('webpage').create();
if (phantom.args.length !== 5) {
console.log('Usage: rasterize.js URL filename width height delay');
phantom.exit();
} else {
var address = phantom.args[0],
output = phantom.args[1],
width = parseInt(phantom.args[2]),
height = parseInt(phantom.args[3]),
@uggedal
uggedal / top.yaml
Created February 3, 2012 09:42
Parameters in top state
base:
'web1':
- nginx:
- hostname: www.uggedal.com
'web1':
- nginx:
- hostname: blog.uggedal.com
node "helium.uggedal.com" inherits servernode {
include europe
hostname { "helium.uggedal.com":
aliases => ["helium", "he"],
}
include sshserver::web
include webserver
include sqlserver
include postgresql::python
#!/bin/sh
#
# <udf name="fqdn" label="Fully qualified domain name" />
PUBLIC_IP_ADDRESS=`ifconfig eth0 | awk -F':' '/inet addr/{split($2,_," ");print _[1]}'`
echo $FQDN > /etc/hostname && hostname -F /etc/hostname
echo $PUBLIC_IP_ADDRESS `hostname` `hostname -s` >> /etc/hosts
/*
* matchMedia() polyfill - test whether a CSS media type or media query applies
* primary author: Scott Jehl
* Copyright (c) 2010 Filament Group, Inc
* MIT license
* adapted by Paul Irish to use the matchMedia API
* http://dev.w3.org/csswg/cssom-view/#dom-window-matchmedia
* which webkit now supports: http://trac.webkit.org/changeset/72552
*
* Doesn't implement media.type as there's no way for crossbrowser property
-- Should return "it works!" for all inputs
function is_it_working(key, value)
return "it works!"
end
-- Return keys with a given prefix for a particular node where there are a
-- known total of nodes. Uses the reamainder of the keys' hash values to
-- segment the keys.
function slice(prefix, index_and_total)
local args = _split(index_and_total, "\t")
if #args ~= 2 then
return nil
end
local index = tonumber(args[1])