Skip to content

Instantly share code, notes, and snippets.

View brandon-beacher's full-sized avatar
💭
🦑

Brandon Beacher brandon-beacher

💭
🦑
View GitHub Profile
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?
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
require 'fastercsv'
class Importer
def self.import_products(folder)
assets = {}
FasterCSV.foreach("#{folder}/assets.csv") do |row|
assets[row[0]] = row[1]
end
class Style < ApplicationModel
before_save :touch_styleable
private
def touch_styleable
styleable.touch
end
end
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
<?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>
<?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>
<?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>
<?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>
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