Skip to content

Instantly share code, notes, and snippets.

View csaunders's full-sized avatar

Christopher Saunders csaunders

View GitHub Profile
#!/usr/bin/ruby
places_to_process = ["~/development/ruby/", "~/development/objc/"].map{|dir| File.expand_path(dir)}
places_to_process.each do |directory|
Dir.chdir(directory)
entries = Dir.entries(".").reject{|i| i.chars.first == "."}
entries.each do |entry|
Dir.chdir(directory + "/" + entry)
system("ctags -R -f .tags")
end
Recipe: users::default
* users_manage[deploy] action create
================================================================================
Error executing action `create` on resource 'users_manage[deploy]'
================================================================================
Net::HTTPServerException
------------------------
404 "Object Not Found"
Next time you feel like mocking another developer for his or her lack of
skills in a certain area, stop yourself. Talk to the person and explain
to them why you think something they are doing is incorrect or how it
could be done better. This way, you don’t come off as a jerk, and the
other developer learns something new and improves. And I’d be surprised
if you didn’t learn something from the experience, too.
@csaunders
csaunders / csv2json.rb
Created December 10, 2012 23:49
Turn CSV into JSON like a boss
require 'rubygems'
require 'csv'
require 'json'
file = CSV.new(File.new('stuff_i_need_to_extract.csv', 'rb'), :headers => true).read
result = []
result = file.map do |row|
extract_data_from_row(row)
@csaunders
csaunders / .gitconfig
Created November 9, 2012 21:04
git-config
[color]
ui = auto
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
@csaunders
csaunders / found_it.sql
Created November 6, 2012 12:34
How do I shot web?
-- kick them to the curb unless they look like mick jagger
delete from measurements as m where m.id
in
(
-- This finds all of our duplicate measurements
select id from measurements
inner join (
select min(id) minid, keg_id, volume from measurements
group by keg_id, volume
having count(1) > 1
# Apply to Shopify API #
Interested in working at Shopify? Don't use that form, you're a
developer and can clearly do better than that!
Instead you can apply to Shopify via our application API. Of course,
for the extra effort you will be given a higher priority than those
who simply apply via the webform.
# How? #
prod = ShopifyAPI::Product.find(6)
before = prod.variants.collect{|v| "#{v.position} - #{v.option1}"}
prod.variants[0].position = 3
prod.variants[2].position = 1
prod.variants.collect(&:save)
prod = ShopifyAPI::Product.find(6)
after = prod.variants.collect{|v| "#{v.position} - #{v.option1}"}
@csaunders
csaunders / LayoutParams.java
Created December 11, 2011 23:41
I can haz layout params?
LinearLayout roundedCell = new LinearLayout(this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
int drawableId = -1;
if(rounded.equals("top")) {
drawableId = R.drawable.list_view_heading_list;
layoutParams.setMargins(0, 0, 0, 1);
} else if(rounded.equals("bot")) {
drawableId = R.drawable.list_view_footer_list;
layoutParams.setMargins(1, 0, 0, 0);
}
@csaunders
csaunders / 1_this.clj
Created September 24, 2011 02:55
Parsing RTM Responses
(defn get-lists
"Calls the rtm api to retrieve lists, returning the attributes from the xml"
[state]
(if-let [list-xml (xml/to-xml (api/rtm-lists-getList state))]
(for [x (xml-seq list-xml) :when (= :list (:tag x))]
(:attrs x))))