- Twitter: @barrettclark
- Blog: http://www.barrettocracy.com/
- Company: Sabre Labs http://sabrelabs.com
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
class String | |
def strip_cruft | |
self.gsub(/ /, '') | |
end | |
def is_palindrome? | |
str = self.strip_cruft | |
str == str.reverse | |
end | |
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
" bind command-/ to toggle comment | |
" requires NERD Commenter to be installed: http://www.vim.org/scripts/script.php?script_id=1218 | |
nmap <D-/> ,c<space> | |
vmap <D-/> ,c<space> | |
imap <D-/> <C-O>,c<space> | |
" bind \d to toggle file browser | |
" requires NERDTree | |
nmap <leader>d :NERDTreeToggle<CR> |
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
require 'rake' | |
# http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html | |
require 'net/http' | |
desc "this is a test" | |
task :testing_rake do | |
puts "Hello from rake!" | |
end | |
namespace :remote_file do |
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
class PascalTriangle | |
def initialize | |
@digits = [] | |
end | |
def calculate_row(row) | |
row = row.to_f | |
0.upto(row) { |column| @digits << calculate_number(row, column).to_i } | |
@digits | |
end |
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
namespace :boot2docker do | |
desc 'Start VM from any states' | |
task :start do | |
%x(boot2docker start > /dev/null 2>&1) | |
end | |
desc 'Setup shell' | |
task :shellinit => [:start] do | |
# NOTE: this does not set the env, so we have to do something different | |
# %x($(boot2docker shellinit > /dev/null 2>&1)) |
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
class WordList | |
attr_reader :words | |
def initialize | |
@words = Array.new | |
read_list | |
end | |
def check_letters(*letters) | |
letter_counts = letters.each_with_object(Hash.new(0)) { |letter, counts| counts[letter] += 1 } |
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
namespace :db do | |
namespace :heroku do | |
desc "capture DB Backup" | |
task :capture_backup => :environment do | |
if Rails.env == 'development' | |
Bundler.with_clean_env do | |
config = Rails.configuration.database_configuration[Rails.env] | |
system "heroku pg:backups capture" | |
end | |
end |
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
WITH raw_data AS ( | |
SELECT jurisdictions AS county, median_value AS value | |
FROM maryland_residential_sales_figures | |
WHERE median_value > 999 | |
), ntiles AS ( | |
SELECT county, | |
value, | |
ROW_NUMBER() OVER (PARTITION BY county ORDER BY value) AS row_number, | |
COUNT(*) OVER (PARTITION BY county ) AS total, | |
NTILE(2) OVER (PARTITION BY county ORDER BY value) AS bitile |
This donut chart is constructed from a CSV file storing the populations of various age groups. The chart employs a number of D3 features:
- d3.csv - load and parse data
- d3.scale.ordinal - color encoding
- d3.svg.arc - display arcs
- d3.layout.pie - compute arc angles from data
OlderNewer