Skip to content

Instantly share code, notes, and snippets.

View thinkerbot's full-sized avatar

Simon Chiang thinkerbot

View GitHub Profile
" Vim color scheme
"
" License: public domain
" Version: 0.1
" Boilerplate: {{{1
set background=light
highlight clear
if exists("syntax_on")
@thinkerbot
thinkerbot / README.md
Created February 4, 2012 03:30
An example of a static site with the tilt extension

Description

This just illustrates how you would setup a static site to be built using the proposed extension to the tilt exe. To build, just run build:

./build

And the compiled site will appear in the site directory. If you wanted to use different layouts or attributes for a specific set of templates, then all you'd have to do is add to the build script.

@thinkerbot
thinkerbot / export.sql
Created January 13, 2012 19:19
Sql tricks
-- sqlplus -S user/pass@conn @export.sql > column_output.txt
set colsep '|'
set echo off
set feedback off
set linesize 1000
set pagesize 0
set sqlprompt ''
set trimspool on
set headsep off
@thinkerbot
thinkerbot / tricks.js
Created January 10, 2012 19:09
Web page tricks
$(function () {
// Activate ghost input text
// <%= text_field_tag :name, @name.blank? ? 'Agent Name' : @name, :class => (@name.blank? ? "inactive" : "active") %>
// input.inactive { color: #D3D3D3; }
$("input.inactive").focus(function() {
input = $(this);
if (input.attr('class') == 'inactive') {
input.attr('value', '');
input.attr('class', 'active');

Gitgo

Provides a mechanism to store issues in git and distribute them in a conflict-free way.

Conversations are treated as directed acyclic graphs where each node is a statement in the conversation. Nodes may only be added to the graphs, they may not be deleted or changed directly. However, when nodes are added to the graph they may be flagged to replace or detach other nodes. These flags may be used

@thinkerbot
thinkerbot / status_cats.sh
Created December 14, 2011 17:53
HTTP status cats
STATUS_CAT_URL="http://www.flickr.com/photos/girliemac/sets/72157628409467125"
curl "$STATUS_CAT_URL" |
grep 'class="photo_container' |
sed -e 's/.*\(src.*\)/\1/' -e 's/class.*//' -e 's/[[:alnum:]]\{1,\}=//g' -e 's/ \{1,\}/ /g' |
tr -d '"' |
cut -d ' ' -f 1,4 |
while read url code
do printf "$code $url\n"
done |
@thinkerbot
thinkerbot / echo_with_lock.sh
Created December 8, 2011 22:29
IPC properties
#!/bin/bash
set -o noclobber
lockfile=${1:-lockfile}
while read line
do
while ! echo "$$" > "$lockfile"
do true #printf "waiting for: $lockfile [$(cat $lockfile)]\n" 1>&2
done 2>/dev/null
@thinkerbot
thinkerbot / mucbot.rb
Created December 7, 2011 22:26
XMPP Multi-User Chat Bot
#!/usr/bin/env ruby
begin
require 'rubygems'
require 'optparse'
require 'highline' # = 1.5.2
require 'xmpp4r' # = 0.5
require 'xmpp4r/muc/helper/simplemucclient'
OptionParser.new do |opts|
opts.banner = %{
@thinkerbot
thinkerbot / README.md
Created November 23, 2011 19:11
Generate a timeseries for splunk

Extended Example (generate apache logs for a 24hr battle of 100k events):

steps=$(ruby normal.rb -s 2 -m 9 -n 25000 -- 0 24)
yes '12.154.191.10 - - [%d/%b/%Y:%H:%M:%S %z] "POST /battle/lasers?color=red HTTP/1.1" 200 -' |
ruby timeseries.rb -s '2011/11/11' -t '2011/11/12' $steps > thebattle.tmp
steps=$(ruby normal.rb -s 2 -m 15 -n 25000 -- 0 24)
yes '204.12.10.120 - - [%d/%b/%Y:%H:%M:%S %z] "POST /battle/lasers?color=blue HTTP/1.1" 200 -' |
ruby timeseries.rb -s '2011/11/11' -t '2011/11/12' $steps >> thebattle.tmp
steps=$(ruby normal.rb -s 3 -m 12 -n 50000 -- 0 24)

cat > events.tmp <

@thinkerbot
thinkerbot / script.R
Created November 22, 2011 20:36
R examples
######################################################
# http://www.r-bloggers.com/ascii-scatterplots-in-r/
source("http://biostatmatt.com/R/scat.R")
x <- sin(seq(0,2*pi,length.out=30))
scat(x, cols=15, rows=8)
# ___________________
# | |
# | * |