This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| def get_column_attrs(width): | |
| """ Creates the specified number of fields and adds them to a dict, | |
| suitable to be used as a model's attrs | |
| """ | |
| attrs = dict( | |
| ('col_{}'.format(i), models.IntegerField(default=1)) | |
| for i in range(0, width) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from optparse import make_option | |
| import os | |
| import subprocess | |
| import urllib2 | |
| from django.conf import settings | |
| from django.core.management.base import BaseCommand | |
| class Command(BaseCommand): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function run { | |
| local command=`cat "$1/command" | grep -o 'bin.*' | cut -d '<' -f 1 | sed "s/'//"` | |
| $command < $1/in.* | |
| } | |
| function debug { | |
| local command=`cat "$1/command" | grep -o 'bin.*' | cut -d '<' -f 1 | sed "s/'//"` | |
| local bin=`echo $command | cut -d '-' -f 1` | |
| local args=`echo $command | grep -o '\-.*'` | |
| echo -n "cmd: $command\tbin: $bin\targs: $args" | |
| echo -n "run $args < $1/in.*" > $1/run.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Notifies you when certain files are changed which necessitate further action on your part. | |
| # | |
| # To enable: | |
| # - copy this file to .git/hooks/post-merge | |
| # - chmod +x .git/hooks/post-merge | |
| commits = `git reflog -n 2`.lines.map { |l| l.split.first } | |
| changed = `git diff --name-only #{commits.first} #{commits.last}`.lines.map &:strip | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'colorize' | |
| require 'csv' | |
| def color? date | |
| date.wday == 5 # Friday | |
| end | |
| CSV.foreach('grid') do |row| | |
| row.each do |cell| | |
| next unless cell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Queue this up manually with `Resque.enqueue LongJob, foo: :bar, ...` | |
| # The extra opts don't do anything, but should show up in the UI | |
| # | |
| # You may want to fiddle around with the @queue / your resque-pool configuration | |
| # for testing purposes. By default, :download is the only queue with 2 workers | |
| # | |
| # Also, you might want to run resque(-pool) with VERBOSE=true | |
| class LongJob | |
| @queue = :download |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| i = rand(2) | |
| i == 0 ? ([] + '') : (foo) | |
| rescue TypeError, NameError => e | |
| puts "oops: #{e.message}" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ~/.tmuxinator/collector.yml | |
| name: collector | |
| root: ~/src/ScoutCollector | |
| # Optional tmux socket | |
| # socket_name: foo | |
| # Runs before everything. Use it to start daemons etc. | |
| # pre: sudo /etc/rc.d/mysqld start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set -g prefix C-b | |
| # remap prefix to Control + a | |
| # unbind C-b | |
| # set -g prefix C-a | |
| bind-key r source-file ~/.tmux.conf \; display-message " Config reloaded ... " | |
| set -g history-limit 50000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| word = ARGV.shift || "FIXME|TODO" | |
| name = ARGV.shift || "James" | |
| lines = `git grep -n -E '#{word}'` | |
| lines.scan /(.*):(\d+)/ do |file, line| | |
| up, down = line.to_i - 2, line.to_i + 5 | |
| blame = `git blame -w -L#{up},#{down} #{file}` | |
| if blame =~ /#{name}.*(#{word})/ |
OlderNewer