This file contains 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
sudo chown -R $USER:admin /usr/local/* |
This file contains 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 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 | |
This file contains 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
# 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: |
This file contains 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
puts 1+2 | |
class Fixnum | |
def +(y) | |
self * y | |
end | |
end | |
puts 1+2 |
This file contains 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 Costume < ActiveRecord::Base | |
extend Namable | |
extend Commentable | |
extend Collectable | |
extend Viewable | |
extend HasPhotos | |
belongs_to :character | |
belongs_to :series | |
belongs_to :variation |
This file contains 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
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>" |
This file contains 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
Lemongrass & Citrus | |
Earl Grey | |
Breakfast Blend | |
Royal Blend | |
Green Tea w/ Yuzu | |
Pu Erh w/ Ginger | |
Irish Cream (really creamy black tea) | |
Apple & Elderflower |
This file contains 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 Parent | |
def self.class_var | |
@@class_var ||= self.name | |
end | |
def self.instance_var | |
@instance_var ||= self.name | |
end | |
end |
This file contains 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 HistoryController < ApplicationController | |
before_filter :get_history, only: [:show, :edit, :update, :destroy] | |
def index | |
@histories = History.all | |
end | |
def show | |
@history = History.find(params[:id]) | |
end |
This file contains 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. Create a variable called test of type boolean and assign the variable the value true. | |
boolean test = true; | |
//2.Create a variable called a of type int and assign the variable the value 5. | |
int a = 5; | |
/*3.Type in an if statement that adds 1 to a if test has value true and subtracts 1 from a if test has value false. | |
Helpful hint: The DrJava interactions pane will evaluate an expression after you hit the return key if what you have typed in is a valid expression. To keep the interactions pane from evaluating your if statement prematurely, either type the entire statement in one line or place the statement inside braces { }*/ | |
if (test == true) { | |
a + 1; | |
} | |
else { |
OlderNewer