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
| commit_time () | |
| { | |
| local repo=`git rev-parse --git-dir 2>/dev/null` | |
| if [ -n "$repo" ]; then | |
| local last=`git log --pretty=format:'%at' -1` | |
| local now=`date +%s` | |
| local m_since=0 | |
| ((m_since=($now - $last) / 60)) |
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
| class OnDestroyMiddleware | |
| def initialize(app, env) | |
| @app = app | |
| end | |
| def call(env) | |
| env["config"].vm.provisioners.each do |provisioner| | |
| env.ui.info "Attempting to remove client #{provisioner.config.node_name}" | |
| `knife client show #{provisioner.config.node_name}` | |
| if $?.to_i == 0 |
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
| [1,1,1,1,2,2,2,1,1,1,3,3,3].inject([]) {|on_boundary_array,x| | |
| if on_boundary_array == [] || on_boundary_array[-1][0] != x | |
| on_boundary_array = on_boundary_array + [[x]] | |
| else | |
| on_boundary_array[-1] << x | |
| end | |
| on_boundary_array | |
| } |
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
| describe '#chunk' do | |
| def chunk(arr) | |
| arr.inject([]) do |chunks, elem| | |
| current_sequence = chunks.last || [] | |
| if elem == current_sequence.last | |
| current_sequence << elem | |
| else | |
| chunks << [elem] | |
| end | |
| chunks |
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
| #!/bin/sh | |
| set -e | |
| last_commit_time="$(git log --pretty=format:'%at' -1)" | |
| current_time="$(date +%s)" | |
| ((minutes_since_last_commit=($current_time - $last_commit_time) / 60)) | |
| # Color Green/Yellow/Red depending on the amount of time since the last commit |
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
| pyths :: Int -> [(Int, Int, Int)] | |
| pyths n = [(x, y, z) | x <- [1..n], y <- [1..n], z <- [1..n], arePyths x y z] | |
| where arePyths x y z = x ^ 2 + y ^ 2 == z ^ 2 |
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 'nokogiri' | |
| require 'yaml' | |
| kml_path = File.join(File.dirname(__FILE__), 'FloodLine_x5.kml') | |
| File.open(kml_path) do |f| | |
| kml = Nokogiri::XML(f) | |
| kml.xpath('//ns:MultiGeometry', {'ns' => "http://www.opengis.net/kml/2.2"}).each do |polygon| | |
| escaped_geometry = con.escape_string(polygon.to_s) | |
| con.exec "INSERT INTO flood_zones VALUES( ST_GEOMFROMKML('#{escaped_geometry}') )" |
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
| vim_plugin_task "gundo", "git://github.com/sjl/gundo.vim.git" |
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 'spec_helper' | |
| require 'stringio' | |
| describe BloomFilter, '#collision?' do | |
| subject { object.collision?(word) } | |
| let(:dictionary) { Dictionary.new } | |
| let(:object) { described_class.new(dictionary) } | |
| context 'checked with a filtered word' do |
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
| - form_for interviewer do |f| | |
| = f.error_messages | |
| = f.label :name, "What is their name?" | |
| = f.text_field :name | |
| #languages | |
| = f.label :languages, "What languages do they speak?" | |
| - f.fields_for :speaks_language do |language_fields| |