Skip to content

Instantly share code, notes, and snippets.

View csaunders's full-sized avatar

Christopher Saunders csaunders

View GitHub Profile
@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 / 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)
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.
Recipe: users::default
* users_manage[deploy] action create
================================================================================
Error executing action `create` on resource 'users_manage[deploy]'
================================================================================
Net::HTTPServerException
------------------------
404 "Object Not Found"
#!/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
@csaunders
csaunders / module_inclusion.rb
Created May 17, 2013 15:00
What are your thoughts on using this style for ensuring modules are able to be included at the top of the file? Is there something in the Ruby runtime I'm missing that would cause this to break?
module AddsFunctionality
extend ActiveSupport::Concern
alias_method :foo, :baz
end
def baz
puts "Hello Baz"
end
end
@csaunders
csaunders / nginx.conf
Created August 8, 2013 04:24
Really confused as to why my nginx 403's when visiting / instead of redirecting to /brews
upstream brewwatcher_server {
server 127.0.0.1:4567 fail_timeout=0;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
@csaunders
csaunders / buildctags.rb
Created August 8, 2013 15:06
A script that I have run via cron to re-index various codebases.
#!/usr/bin/ruby
places_to_process = ["~/development/ruby/"].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
@csaunders
csaunders / my_fancy_test.rb
Created September 16, 2013 21:47
The way I try to drive my TDD
class MyFancy
end
describe "MyFancy" do
it "should be able to be very fancy"
it "should be possible to set my level of fancy"
it "should add a number of exclamation points equal to the fancy level"
@csaunders
csaunders / posts.js.coffee
Created September 28, 2013 13:17
Why am I getting the error Uncaught TypeError: Object post has no method '_create' when trying to create a new post?
Blember.Post = DS.Model.extend
title: DS.attr('string'),
isCompleted: DS.attr('boolean')
Blember.Post.FIXTURES = [
{
id: 1,
title: 'Hello World',
body: 'This is my first post',
isCompleted: true