Skip to content

Instantly share code, notes, and snippets.

View evie404's full-sized avatar

Evelyn Pai evie404

  • San Francisco, CA
View GitHub Profile
@evie404
evie404 / gist:cbbc5f23b1f7a3a99043
Created January 23, 2015 11:00
十萬個為什麼
十萬 = 100_000
class Fixnum
def 個
times.map { yield }
end
end
puts 十萬.個 { "為什麼" }
@evie404
evie404 / love_testing
Last active August 29, 2015 14:25
How I Learned to Love Testing
Better Testing in Ruby (or "How I Learned to Love Testing")
==============================
Introduction:
- Ricky
- Software Engineering @ Airbnb (Previous: Twitter, Aniarc)
Beginning:
- "I wrote the code, I already know it works!"
@evie404
evie404 / gist:3895535
Created October 15, 2012 21:13
fix brew permission problems
sudo chown -R $USER:admin /usr/local/*
class Photo < ActiveRecord::Base
#...
def image_url *args
url = super
url.gsub!('.', '@2x.') if args[0] == :square_thumb #add @2x to filename if square_thumb is requested
url
end
# I use nateware/redis-objects as an easy way to implement atomic counters in my ActiveRecord models in Rails.
# But I still need counters in sql to sort models with them.
# So the CounterSyncWorker goes through the object space, selects all class that is an AR model and includes Redis::Objects,
# check for all columns that have _sql equivalents, fetches the value in redis and store into the AR attribute.
# Example:
# when uploading a photo that belongs to first user:
@evie404
evie404 / gist:5347970
Created April 9, 2013 18:09
Don't try this at home
puts 1+2
class Fixnum
def +(y)
self * y
end
end
puts 1+2
class Costume < ActiveRecord::Base
extend Namable
extend Commentable
extend Collectable
extend Viewable
extend HasPhotos
belongs_to :character
belongs_to :series
belongs_to :variation
Hi all,
I recently attended a local tech meetup where they talked about the deficiencies of javascript and the prominence of this new coffeescript language and how it improves developer productivity. For example, instead of stitching strings together in an old and ugly way:
str = "<a href=\""+url+"\">"+text+"</a>"
you can write in a rubyique way:
str = "<a href=\"#{url}\">#{text}</a>"
Lemongrass & Citrus
Earl Grey
Breakfast Blend
Royal Blend
Green Tea w/ Yuzu
Pu Erh w/ Ginger
Irish Cream (really creamy black tea)
Apple & Elderflower
@evie404
evie404 / class_var.rb
Last active December 21, 2015 05:18
Class variable propagates to child classes in Ruby
class Parent
def self.class_var
@@class_var ||= self.name
end
def self.instance_var
@instance_var ||= self.name
end
end