Skip to content

Instantly share code, notes, and snippets.

@iangreenleaf
iangreenleaf / bitcoin_idle
Created June 2, 2011 02:04
Bitcoin mining when idle
#!/bin/bash
# Monitors for signals from gnome-screensaver and activates or deactivates
# bitcoin miners accordingly.
# Params to the mining programs are all hardcoded. Change 'em manually. Leave the "&"s.
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'" | \
while read line; do
case "$line" in
@iangreenleaf
iangreenleaf / gist:941090
Created April 25, 2011 19:57
CSS makes my head hurt
<!DOCTYPE html>
<html>
<head>
<title>Hola</title>
</head>
<body style="background-color: gray;">
<div id="outer" style=" background-color:pink;">
<div style="width:5000px; height:200px; background-color: green;">
Hi
</div>
@iangreenleaf
iangreenleaf / gist:935741
Created April 21, 2011 23:58
Git interrogation oneliners
# Cumulative totals of lines added/deleted
git log --numstat STARTING_HASH..ENDING_HASH -M | grep '^[0-9]\+[[:space:]]\+[0-9]\+[[:space:]]' | awk '{added+=$1} {deleted+=$2} END { print added, deleted }'
@iangreenleaf
iangreenleaf / gist:908604
Created April 7, 2011 20:07
the best horoscope I've received

Thoughtful to the extreme, you are often obsessed with perfection and the rules governing your own personal interests. Your world is black and white. You love to work within a logical system, such as language, computer programming, or mathematics. Manipulating a system that can be completely understood is a distinct pleasure to you, because of your confidence in the underlying veracity of your belief system. Because of your appreciation for logic and order, those who speak or think in a sloppy manner are apt to generate more than their share of wrath. Although very amiable, you are not drawn to friendships out of a sense of personal need. You are just as happy by yourself with a good book or puzzle. Because you are so involved with thought, you will on occasion have difficulty dealing with the day-to-day problems of a normal life. Taking out the trash, doing the dishes, these are often left until the last possible moment, if at all.

@iangreenleaf
iangreenleaf / yaml.vim
Created March 15, 2011 17:38
Dumb-smart indentation for Yaml
" Vim indent file
" Language: Yaml
" Author: Ian Young
" Get it bundled for pathogen: https://github.com/avakhov/vim-yaml
if exists("b:did_indent")
finish
endif
"runtime! indent/ruby.vim
"unlet! b:did_indent
@iangreenleaf
iangreenleaf / scopes.md
Created March 11, 2011 17:01
Scopes are awesome (stop writing SQL)

Stop writing SQL

Refresher

named_scope in 2.x.

named_scope :active, :conditions => { :status => "activo" }

Just scope now.

scope :active, where( :status => "activo" )

@iangreenleaf
iangreenleaf / .gitconfig
Created October 23, 2010 00:11
My .gitconfig
[core]
excludesfile = /Users/ian/.gitignore
[color]
ui = auto
[alias]
co = checkout
st = status
br = branch
ci = commit
m = checkout master
@iangreenleaf
iangreenleaf / .gitconfig
Created September 20, 2010 21:30
Better diffs in git
[diff "ruby"]
wordRegex = (@@?|\\b:|[^:]:)?[[:alnum:]_]+|:\"[^\"]+\"|::|[^[:space:]]
[diff "php"]
wordRegex = \\${0,2}[[:alnum:]_]+|::|->|[^[:space:]]
# Mergesort
# precondition: no nils in the array
def sort some_array
return some_array if some_array.length == 1
half_length = some_array.length / 2
first_half = sort(some_array[0,half_length])
second_half = sort(some_array[half_length, some_array.length - half_length])
result = []
@iangreenleaf
iangreenleaf / gist:562724
Created September 2, 2010 18:47
Impromptu Scheme session
;; Semicolons are comments
> (+ 2 4)
6
> (+ 2 4 8)
14
> (define double (lambda (a) (+ a a)))
> (double 3)
6
> '(1 2 3) ; this is a list
(1 2 3)