This file contains 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 bash | |
set -Eeuo pipefail | |
trap cleanup SIGINT SIGTERM ERR EXIT | |
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) | |
usage() { | |
cat <<EOF | |
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...] |
This file contains 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 RSpecCommands(bang) | |
if !a:bang | |
noremap <Leader>t :!bundle exec rspec %<CR> | |
noremap <Leader>T :!bundle exec rspec %:<C-R>=line('.')<CR><CR> | |
else | |
silent! nunmap <Leader>t | |
silent! nunmap <Leader>T | |
endif | |
endfunction |
This file contains 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
<?xml version="1.0"?> | |
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> | |
<fontconfig> | |
<!-- | |
Documented at | |
http://linux.die.net/man/5/fonts-conf | |
To check font mapping run the command at terminal | |
$ fc-match 'helvetica Neue' |
This file contains 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
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |
This file contains 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
# ~/.gitconfig from @boblet | |
# initially based on http://rails.wincent.com/wiki/Git_quickstart | |
[core] | |
excludesfile = /Users/oli/.gitignore | |
legacyheaders = false # >git 1.5 | |
quotepath = false | |
# http://stackoverflow.com/questions/136178/git-diff-handling-long-lines | |
pager = less -r | |
# if ↑ doesn’t work, try: pager = less -+$LESS -FRX |
This file contains 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
#!/bin/sh | |
# | |
# new_server.sh | |
# Author: Sam Soffes | |
# Created: 02/25/2010 | |
# Updated: 11/04/2010 | |
# | |
# See my blog post on this script: http://samsoff.es/posts/new-server-script | |
# | |
# This script installs everything needed to run a Ruby on Rails application on |
This file contains 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
### /config/environment.rb | |
config.gem 'fastercsv' | |
### /config/routes.rb | |
map.connect '/users/export', :controller => 'users', :action => 'export' | |
### /app/models/user.rb | |
# find all students and pass to controller export action for export to csv | |
def self.find_students | |
find_by_sql("select students.firstname, students.lastname, students.grade, students.homeroom, students.phone, students.email, students.relationship, users.firstname, users.lastname, accounts.school from students, users, accounts where students.user_id = users.id and accounts.id = users.account_id") |
This file contains 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
def euclidean_distance(p1,p2) | |
sum_of_squares = 0 | |
p1.each_with_index do |p1_coord,index| | |
sum_of_squares += (p1_coord - p2[index]) ** 2 | |
end | |
Math.sqrt( sum_of_squares ) | |
end | |
require 'test/unit' | |
class EuclideanDistanceTest < Test::Unit::TestCase |