Skip to content

Instantly share code, notes, and snippets.

@pfig
pfig / add_usernames.pl
Created August 26, 2009 10:16
Fills in "FirstName LastName" for users who don't have it set on /etc/passwd
my ( $name, @u );
while ( @u = getpwent() ) {
if ( $u[0] =~ /^\w+\.\w+$/ && $u[6] eq '' ) {
( $name = $u[0] ) =~ s/(\w+)\.(\w+)/ucfirst($1).' '.ucfirst($2)/e;
system( '/usr/sbin/usermod', '-c', $name, $u[0] );
}
}
@pfig
pfig / hexdump.pl
Created March 23, 2010 12:24
Convert a decimal integer to hex without using pack().
my @HEX_CHARS = qw( 0 1 2 3 4 5 6 7 8 9 A B C D E F );
my $hex = $HEX_CHARS[($value >> 4) & 0xF] . $HEX_CHARS[($value) & 0xF];
@pfig
pfig / Vuvuzela in SuperCollider.sc
Created June 19, 2010 16:34
Vuvuzela sound in SuperCollider
{
[
( Blip.ar( XLine.kr( 233, 200, 6 ), 100, 2.5 ) ),
( Blip.ar( 466, Line.kr( 1, 100, 1 ), 2.5 ) ),
( Blip.ar( 932, Line.kr( 1, 100, 1 ), 2.5 ) ),
( Blip.ar( 1864, Line.kr( 1, 100, 1 ), 2.5 ) )
]
}.play;
@pfig
pfig / perl_smoker
Created May 21, 2011 21:21 — forked from melo/perl_smoker
Script to use with Jenkins to smoke a Perl module
#!/bin/sh
#
# Use this as Jenkins Build "Execute shell" script
#
# Pedro Melo <melo@simplicidade.org>
## Die on any errors
set -ex
export OUTPUT=$WORKSPACE/logs
@pfig
pfig / gist:1400027
Created November 28, 2011 11:13
The Alternative Christmas Party Escape Protocol
Alternative Christmas Part Working Group
Request for Comments: TBC
Category: Entertainment
November 2011
Alternative Christmas Party Escape Protocol
Status of this Memo
@pfig
pfig / gist:1639577
Created January 19, 2012 11:53
Just testing the creation of gists from Sublime Text 2
event_name
@pfig
pfig / mkfavicon.sh
Created February 12, 2012 12:01
Make a multi-resolution favicon.ico from a source image, using ImageMagick
#!/bin/bash
# from
# http://bergamini.org/computers/creating-favicon.ico-icon-files-with-imagemagick-convert.html
convert source-WxW.png -resize 256x256 -transparent white favicon-256.png
convert favicon-256.png -resize 16x16 favicon-16.png
convert favicon-256.png -resize 32x32 favicon-32.png
convert favicon-256.png -resize 64x64 favicon-64.png
convert favicon-256.png -resize 128x128 favicon-128.png
@pfig
pfig / Rakefile
Created March 3, 2012 23:48
Rake task to compile Less to CSS
require 'rubygems'
require 'less'
require 'rake'
SOURCE = "."
LESS = File.join( SOURCE, "path", "to", "less", "files" )
CONFIG = {
'less' => File.join( LESS, "less" ),
'css' => File.join( LESS, "css" ),
'input' => "style.less",
@pfig
pfig / lessc.rake
Created March 25, 2012 09:09
Task to compile LESS in jekyll-bootstrap
#
# Save this in _rake/lessc.rake
#
require 'less'
LESS = File.join(SOURCE, "assets", "themes", "twitter") # set theme here
CONFIG['less'] = File.join(LESS, "less")
CONFIG['css'] = File.join(LESS, "css")
CONFIG['input'] = "style.less"
@pfig
pfig / compile-nginx.sh
Created April 9, 2012 07:48
Compile nginx
#!/bin/bash
set -e
./configure \
--prefix=/usr/local \
--conf-path=/usr/local/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \