git (private server)
Alternative: github
Cashboard
| /(?<area_code>\d{3}) (?<local_number>\d{3}-\d{4})/ =~ "123 456-7890" | |
| local_variables # => [:area_code, :local_number] | |
| area_code # => "123" | |
| local_number # => "456-7890" |
| # coding: utf-8 | |
| require 'sinatra' | |
| set server: 'thin', connections: [] | |
| get '/' do | |
| halt erb(:login) unless params[:user] | |
| erb :chat, locals: { user: params[:user].gsub(/\W/, '') } | |
| end | |
| get '/stream', provides: 'text/event-stream' do |
| // Dimensions of devices | |
| // iPad Retina - 1536x2048 | |
| // iPad - 768x1024 | |
| // iPhone - 320x480 | |
| // iPhone Retina - 640x960 | |
| @mixin mobile-only { | |
| @media only screen and (max-width : 480px) { | |
| @content; | |
| } |
| def reorder | |
| redirect_to confirm_order_path and return if params[:reorder] == current_order.id.to_s | |
| reorder = current_user.orders.find(params[:reorder]) | |
| redirect_to favorites_order_path, :notice => 'The order is no longer available.' and return if reorder.nil? | |
| redirect_to favorites_order_path, :notice => 'There are items in your cart. Please cancel your current order before reordering.' and return if (current_order.items.any?) | |
| search_result = reorder.next_available_delivery |
| new_order = reorder.xerox | |
| new_order.save | |
| current_order.destroy | |
| current_order = new_order | |
| current_order.status = 'open' | |
| current_order.favorite = false | |
| current_order.created_at = DateTime.now | |
| current_order.updated_at = DateTime.now | |
| current_order.mealsoft_response = nil | |
| current_order.error_message = nil |
| class QueryTracer < ActiveSupport::LogSubscriber | |
| ACCEPT = %r{^(app|config|lib)}.freeze | |
| FRAMES = 5 | |
| THRESHOLD = 300 # In ms | |
| def sql(event) | |
| return unless event.duration > THRESHOLD | |
| callers = Rails. | |
| backtrace_cleaner. |
| >> case "String".class | |
| >> when String | |
| >> puts "I'm a string" | |
| >> else | |
| ?> puts "I can't tell what I am" | |
| >> end | |
| I can't tell what I am |
| class Post < ActiveRecord::Base | |
| has_many :authors | |
| has_many :post_comments | |
| attr_accessor :post_authors_cache, :post_comments_cache | |
| def post_authors | |
| @post_authors_cache ||= begin | |
| process_post |
| class Post < ActiveRecord::Base | |
| has_many :authors | |
| has_many :post_comments | |
| attr_accessor :post_authors_cache, :post_comments_cache | |
| def post_authors | |
| process_post if post_authors_cache.nil? | |
| post_authors_cache |