Skip to content

Instantly share code, notes, and snippets.

View bertrandom's full-sized avatar

Bertrand Fan bertrandom

View GitHub Profile
@bertrandom
bertrandom / westernunion.js
Created November 18, 2011 21:32
Daemon for queueing tasks for the future for Gearman without using SUBMIT_JOB_EPOCH
require('js-yaml');
function writeLn(line) {
var now = new Date();
console.log(now.toGMTString() + ' - [' + jobs + '] - ' + line);
}
function executeJob(data) {
if (!connection_working) {
@bertrandom
bertrandom / gist:1405715
Created November 29, 2011 17:54
un t.co function
<?php
public function getLinkifiedText() {
$text = $this->getTweetText();
$entities = new \stdClass;
if ($urls = $this->getEntitiesUrls()) {
$urls = unserialize($urls);
_____ totally vegan
/
,;'OO';, ,;'OO';, ,;'OO';,
|',_OO_,'| |',_OO_,'| |',_OO_,'|
| | | | | |
'.____.' '.____.' '.____.'
@bertrandom
bertrandom / install-graphite-ubuntu-11.10.sh
Created December 19, 2011 15:20 — forked from spatzle/install-graphite-ubuntu-11.10.sh
Install Graphite 0.9.9 (works on Ubuntu 11.04)
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# Forked from: http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Ubuntu 11.04
# Last tested & updated 10/14/2011
####################################
#sudo apt-get update
#sudo apt-get dist-upgrade
@bertrandom
bertrandom / geartop
Created January 6, 2012 19:22
top for gearman
alias geartop='watch "gearadmin --status | grep -v -P '"'0\t0\t'"'"'
@bertrandom
bertrandom / ephemswap
Created March 20, 2012 04:56
Creates a 4 gig swap file and mounts it as swap space, used for EC2 small instances for on-boot ephemeral swap space, put it somewhere in boot init
#!/bin/bash
if swapon -s | grep -q /mnt/swapfile
then
echo "Swapfile already mounted"
else
if [ -e /mnt/swapfile ]
then
echo "Mounting swapfile"
swapon /mnt/swapfile
@bertrandom
bertrandom / gist:2393966
Created April 15, 2012 17:19
Script for displaying all the available 256 colors in the terminal, for prompt customization wankery
#!/bin/bash
function fgcolor {
echo "\033[38;5;"$1"m"
}
for i in `seq 1 256`
do
echo -e "$(fgcolor $i)color-$i"
done
@bertrandom
bertrandom / gist:2961106
Created June 20, 2012 17:39
Removes the Bing logo from Satellite Eyes wallpapers
#!/bin/bash
#
# Removes the Bing logo from Satellite Eyes wallpapers
#
# Delete the Bing logo image
rm -f /Applications/Satellite\ Eyes.app/Contents/Resources/bing-logo.png
# Clear the map cache
rm -f ~/Library/Application\ Support/Satellite\ Eyes/map-*.png
@bertrandom
bertrandom / gist:4262137
Created December 11, 2012 21:05
Recursive square thumbnail generation (destructive)
find . -type f -name '*.jpg' | xargs mogrify -define jpeg:size=640x640 -thumbnail 320x320^ -gravity center -extent 320x320
@bertrandom
bertrandom / storedata.sh
Created April 12, 2013 20:31
tourbillion performance testing
#!/bin/bash
i=0
while true
do
i=$(($i+1))
status=$(curl -H 'Content-Type: application/json' --request POST --data '{"data":"Goodbye world!"}' --write-out %{http_code} --silent https://tourbillon.herokuapp.com/dev/null)
if [ "$status" -eq 200 ]
then
echo "$i Discarded successfully."
else