This file contains hidden or 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 bash | |
| gem uninstall rubygems-update | |
| gem install rubygems-update --version $1 | |
| update_rubygems |
This file contains hidden or 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
| <div id="map"></div> | |
| <div id="map-side-bar"> | |
| <div class="map-location" data-jmapping="{id: 1, point: {lng: -122.2678847, lat: 37.8574888}, category: 'market'}"> | |
| <a href="#" class="map-link">Berkeley Bowl</a> | |
| <div class="info-box"> | |
| <p>A great place to get all your groceries, especially fresh fruits and vegetables.</p> | |
| </div> | |
| </div> | |
| </div> |
This file contains hidden or 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 ApplicationController < ActionController::Base | |
| rescue_from ActiveRecord::StaleObjectError do |exception| | |
| respond_to do |format| | |
| format.html { | |
| correct_stale_record_version | |
| stale_record_recovery_action | |
| } | |
| format.xml { head :conflict } | |
| format.json { head :conflict } | |
| end |
This file contains hidden or 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
| # app/metal/resque_web.rb | |
| # Allow the metal piece to run in isolation | |
| require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) | |
| require 'resque/server' | |
| Resque::Server.use Rack::Auth::Basic do |username, password| | |
| username == 'admin' && password == 'password' | |
| end | |
| ResqueWeb = Rack::URLMap.new("/resque" => Resque::Server.new) |
This file contains hidden or 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
| ~ $ brew install -v io | |
| ==> Build Environment | |
| CC: /usr/bin/cc => /usr/bin/gcc-4.2 | |
| CXX: /usr/bin/c++ => /usr/bin/c++-4.2 | |
| LD: /usr/bin/cc => /usr/bin/gcc-4.2 | |
| CFLAGS: -O3 -march=core2 -w -pipe | |
| CXXFLAGS: -O3 -march=core2 -w -pipe | |
| MAKEFLAGS: -j2 | |
| PKG_CONFIG_PATH: /usr/local/lib/pkgconfig | |
| /usr/local/bin/git |
This file contains hidden or 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
| File read := method(path, | |
| fileToRead := File with(path) openForReading | |
| content := fileToRead readToEnd | |
| fileToRead close | |
| return content | |
| ) | |
| # Pulled from http://iota.flowsnake.org/syntax-extensions.html | |
| Object squareBrackets := method( | |
| r := List clone |
This file contains hidden or 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 ruby -KU | |
| require 'optparse' | |
| require 'ostruct' | |
| require 'iconv' | |
| SCRIPT_NAME = "File Character Encoding Converter" | |
| SCRIPT_VERSION = "0.1" | |
| class FileEncodingConverterOptionParser |
This file contains hidden or 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 Duplicatable | |
| def duplicate_name(no_spaces = false) | |
| new_name = no_spaces ? "#{self.name}_Copy" : "#{self.name} Copy" | |
| replace_name = no_spaces ? "#{new_name}_" : "#{new_name} " | |
| find_options = {:conditions => ["name LIKE ?", "#{new_name}%"], | |
| :order => "copy_number DESC", | |
| :select => "id, CAST(REPLACE(name, '#{replace_name}', '') AS UNSIGNED INTEGER) AS copy_number"} | |
| last_copy = self.class.respond_to?(:find_with_deleted) ? | |
| self.class.find_with_deleted(:first, find_options) : | |
| self.class.first(find_options) |
This file contains hidden or 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
| [master] ~/Projects/rails_app $ script/console | |
| Loading development environment (Rails 2.3.8) | |
| rails_app(development):001:0> m = MyModel.new | |
| => #<MyModel id: nil, name: nil, date: nil> | |
| rails_app(development):002:0> m.date = "bad date words" | |
| => "bad date words" | |
| rails_app(development):002:0> m.date | |
| => nil |
This file contains hidden or 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
| # From: http://scie.nti.st/2007/2/1/let-activerecord-observers-see-controller-context | |
| # By Garry Dolley | |
| # MIT / X11 licensed | |
| module EnlightenObservers | |
| def self.included(base) | |
| base.extend(ClassMethods) | |
| end | |
| module ClassMethods |