Skip to content

Instantly share code, notes, and snippets.

@localshred
localshred / counts.json
Created July 21, 2014 17:46
jq is the bomb.com
{"results":[{"timePeriod":"201406100000","count":0},{"timePeriod":"201406110000","count":0},{"timePeriod":"201406120000","count":0},{"timePeriod":"201406130000","count":0},{"timePeriod":"201406140000","count":0},{"timePeriod":"201406150000","count":0},{"timePeriod":"201406160000","count":0},{"timePeriod":"201406170000","count":0},{"timePeriod":"201406180000","count":0},{"timePeriod":"201406190000","count":27},{"timePeriod":"201406200000","count":26},{"timePeriod":"201406210000","count":35},{"timePeriod":"201406220000","count":3},{"timePeriod":"201406230000","count":6},{"timePeriod":"201406240000","count":14},{"timePeriod":"201406250000","count":9},{"timePeriod":"201406260000","count":37},{"timePeriod":"201406270000","count":32},{"timePeriod":"201406280000","count":10},{"timePeriod":"201406290000","count":8},{"timePeriod":"201406300000","count":44},{"timePeriod":"201407010000","count":47},{"timePeriod":"201407020000","count":52},{"timePeriod":"201407030000","count":920},{"timePeriod":"201407040000","count":89}
beach(Temperature) ->
case Temperature of
{celsius, N} when N >= 20, N =< 45 ->
'favorable';
{kelvin, N} when N >= 293, N =< 318 ->
'scientifically favorable';
{fahrenheit, N} when N >= 68, N =< 113 ->
'favorable in the US';
_ ->
'avoid beach'
@localshred
localshred / rambling.txt
Last active August 29, 2015 14:11
India rambling for 20 minutes straight at bedtime 2014-12-17
So... we need... purple lights.... and... pink glitter... and pink purple lights... pink lights... and sparkle lights... and pink lights... and purple lights... and pink lights and purple lights and sparkle lights... and sparkle stars... and everything will be ALL done dad. You can put the balloons up. You and mommy can put my sparkle balloons up and my pink balloons up and my purple table. Just tangle them around and the thing will be all done. And i'll put some baby rainbows and you and mommy can put up pink and baby rainbows. And you can set up the mommy and daddy rainbows. And we can have, you and mommy can put up my balloons. K? And I can put up the baby balloons and you can setup the momma balloons, and the daddy balloons too. I'm gonna setup the baby rainbows. Bella's gonna setup my sparkle rainbows. And anders is gonna setup his very own sparkle rainbow. And I'm gonna Elsa capes I'm just doing so anybody won't cut 'em. And elsa's braids and anna's braids. K? I'm gonna setup the baby elsa braid and the
@localshred
localshred / higher_order_list_handling.rb
Last active August 29, 2015 14:21
Handling lists with higher-order functions
require "awesome_print"
##
# The term "higher-order" is meant to describe a function that
# takes other functions as arguments, produces a function as a return value,
# or both.
#
# ----> tl;dr use higher-order functions for working with lists as opposed to general "for loop" iteration.
#
@localshred
localshred / git-workflow.sh
Created October 16, 2009 05:34
My simple git workflow for using topic branches
# This is a simple descriptor on how I do topic development using git
# Some of the commands are java flavored (like ant),
# but that doesn't mean you can't use this with other languages.
# Step 1 - Synchronize master.
# 1.1 - Checkout master branch
# 1.2 - Get changes from origin
git checkout master
git pull
@localshred
localshred / sql_like.rb
Created October 29, 2009 03:55
It always bugged me that there isn't really a "rails-style" way to do like syntaxes with active record. So, one day while building a keyword search on the users table, I decided to roll my own. I've thought about making this more ActiveRecord friendly, bu
# Build a condition array from the provided keywords and a specific set of fields to search on
# Take out any keywords that are 2 chars or less
def self.find_by_keywords(keywords)
# Columns to do keyword searching on
fields = %w{ user_name email }
# Strip all words 2 chars or less, then split into an array
keywords = keywords.gsub(/\b\S{1,2}\b/, "").strip.downcase.split(/\s+/)
unless (keywords.nil? || keywords.empty?)
class LibraryController > ApplicationController
...
def index
@file_tree = AudioLib.build_tree
end
...
end
@localshred
localshred / deploy.rb
Created February 4, 2010 23:03 — forked from richievos/bundler_cap.rb
Using Bundler 0.9.1 with Capistrano
# ...
namespace :bundler do
task :create_symlink, :roles => :app do
shared_dir = File.join(shared_path, 'bundle')
release_dir = File.join(current_release, '.bundle')
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
end
task :bundle_new_release, :roles => :app do
$ cap shell
* executing `shell'
====================================================================
Welcome to the interactive Capistrano shell! This is an experimental
feature, and is liable to change in future releases. Type 'help' for
a summary of how to use the shell.
--------------------------------------------------------------------
cap> which bundle
[establishing connection(s) to mydomain.com]
error: failed: "sh -c 'which bundle'" on mydomain.com