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
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
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
module CalculateUntilSaved | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def calculate_until_saved(attribute_name) | |
attr_protected attribute_name |
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
@timer = Time.now | |
def log(line) | |
puts "#{(Time.now - @timer).round(4)} #{line}" | |
@timer = Time.now | |
end | |
module Kernel | |
def require_logged(required, *args) | |
puts "require(#{required})" | |
require_not_logged(required, *args) |
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
def redirect_if_current_locale_not_requested_locale | |
if session[:requested_locale].present? && Language::SUPPORTED_LANGUAGES.include?(session[:requested_locale].to_sym) | |
if geo_locator_slug = GeoLocatorSlug.find_by_slug_and_language(params[:locator_slug], session.delete(:requested_locale).to_sym) | |
geo_locator_slug = geo_locator_slug.slug_for_new_language(current_language) | |
redirect_to locator_path(geo_locator_slug.to_param) if geo_locator_slug.present? | |
end | |
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
# places/index.rabl | |
object false | |
node(:total_entries) { @places.total_entries} | |
node(:total_pages) { @places.total_pages} | |
node(:current_page) { @places.current_page} | |
node(:per_page) { @places.per_page} | |
node :places do | |
@places.map { |place| {:place => partial('api/v1/places/show', :object => place)} } | |
end | |
node(:links) do |
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
# places/index.api | |
@places.each do |place| | |
template('places/show', :place => place) # user shall be available as @user in the template | |
end | |
# places/show.api | |
object(@place) do | |
:name, # plain attribute | |
:address => address_for(@user), # helper used | |
:location => { # hash |
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
object @place => :place | |
# this is a hack, but otherwise the partial mechanism doesn't work yet [thorsten, 2011-10-07] | |
@place = @_data.is_a?(Hash) ? @_data.keys.first : @_data | |
attributes :name, :city, :street, :slug, :zipcode, :phone, :number_of_beds, :number_of_bedrooms, | |
:currency, :lat, :lng, :scouts_approved_at, :district, :number_of_bathrooms, :cancellation_rules, | |
:charge_per_extra_person, :minimum_nights, :maximum_nights, :bed_type, | |
:size, :manual, :house_rules, :pets_around, :emergency_phone, :bathroom_type, :cleaning_fee, | |
:charge_per_extra_person_limit, :favorites_count, :state, :amenities_list |
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 A | |
class << self | |
def class | |
class << self | |
self | |
end | |
end | |
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
Started GET "/place_matches" for 77.6.249.160 at Wed Mar 30 11:07:48 +0000 2011 | |
Processing by PlaceMatchesController#index as HTML | |
User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 8 AND (users.deleted_at IS NULL) LIMIT 1 | |
SQL (0.3ms) SELECT COUNT(*) FROM `questions` | |
SQL (12.7ms) SELECT COUNT(*) FROM `questions` INNER JOIN `answerings` ON `questions`.id = `answerings`.question_id WHERE ((`answerings`.user_facade_id = 8) AND (`answerings`.user_facade_type = 'User')) | |
TagAffinity Load (8.0ms) SELECT `tag_affinities`.* FROM `tag_affinities` WHERE (`tag_affinities`.affinityable_id = 8 AND `tag_affinities`.affinityable_type = 'User') | |
SQL (0.3ms) BEGIN | |
SQL (0.3ms) COMMIT | |
Answering Load (14.8ms) SELECT `answerings`.* FROM `answerings` WHERE (`answerings`.user_facade_id = 8 AND `answerings`.user_facade_type = 'User') | |
Answer Load (0.5ms) SELECT `answers`.* FROM `answers` WHERE `answers`.`id` = 12 LIMIT 1 |
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 MyClass | |
class << self | |
def class; class << self; self; end; end | |
end | |
end |