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 Array | |
def adjoin(*args) | |
options = args.last.is_a?(Hash) ? args.pop : {} | |
separators = args | |
raise ArgumentError unless length == separators.length + 1 | |
prefix = first.dup | |
separators.each_with_index do |separator, index| | |
suffix = at(index + 1) | |
prefix << separator if prefix.present? && suffix.present? |
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
SSL Requirement | |
=============== | |
SSL requirement adds a declarative way of specifying that certain actions | |
should only be allowed to run under SSL, and if they're accessed without it, | |
they should be redirected. | |
Example: | |
class ApplicationController < ActiveRecord::Base |
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
require 'fastercsv' | |
class Importer | |
def self.import_products(folder) | |
assets = {} | |
FasterCSV.foreach("#{folder}/assets.csv") do |row| | |
assets[row[0]] = row[1] | |
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 Style < ApplicationModel | |
before_save :touch_styleable | |
private | |
def touch_styleable | |
styleable.touch | |
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
module Primaryable | |
def self.included(base) | |
base.before_create :create_primary | |
base.before_destroy :destroy_primary | |
base.before_save :save_primary | |
base.before_update :update_primary | |
base.named_scope :primary_first, { :order => "`primary` desc" } | |
base.named_scope :primary_last, { :order => "`primary` asc" } | |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<kml xmlns="http://earth.google.com/kml/2.0"> | |
<Response> | |
<name>123 N Pelham Rd, 30324, US</name> | |
<Status> | |
<code>200</code> | |
<request>geocode</request> | |
</Status> | |
<Placemark id="p1"> | |
<address>123 N Pelham Rd, NJ 08043, USA</address> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<kml xmlns="http://earth.google.com/kml/2.0"> | |
<Response> | |
<name>123 N Pelham Rd, 30306, US</name> | |
<Status> | |
<code>200</code> | |
<request>geocode</request> | |
</Status> | |
<Placemark id="p1"> | |
<address>123 N Pelham Rd, NJ 08043, USA</address> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<kml xmlns="http://earth.google.com/kml/2.0"> | |
<Response> | |
<name>123 N Pelham Rd, GA, 30324, US</name> | |
<Status> | |
<code>200</code> | |
<request>geocode</request> | |
</Status> | |
<Placemark id="p1"> | |
<address>North Pelham Rd NE, Atlanta, GA 30324, USA</address> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<kml xmlns="http://earth.google.com/kml/2.0"> | |
<Response> | |
<name>123 N Pelham Rd, GA, 30306, US</name> | |
<Status> | |
<code>200</code> | |
<request>geocode</request> | |
</Status> | |
<Placemark id="p1"> | |
<address>North Pelham Rd NE, Atlanta, GA 30324, USA</address> |
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
root@ip-10-251-197-239:~# ps x | grep mong | |
9257 pts/0 R+ 0:00 grep mong | |
9290 ? Sl 42:04 mongrel_rails [8000/0/59703]: idle | |
9293 ? Sl 42:01 mongrel_rails [8001/0/59626]: idle | |
9296 ? Sl 41:51 mongrel_rails [8002/1/59868]: handling 10.251.197.239: GET /dfc/newsdetail_2/15 | |
9299 ? Sl 42:12 mongrel_rails [8003/0/59540]: idle |