View polymorphic_eagerload.rb
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
gem 'activerecord', '4.1.0.rc1' | |
# gem 'activerecord', '4.0.2' | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
puts ActiveRecord::VERSION::STRING | |
ActiveRecord::Base.logger = Logger.new(STDOUT) |
View index.html
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' /> | |
<style> | |
body { margin:0; padding:0; } | |
#map { position:absolute; top:0; bottom:0; width:100%; } | |
.marker-properties { | |
border-collapse:collapse; |
View multi_xml_bug.rb
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 "multi_xml" | |
# copy paste above xml document to `xml` variable | |
MultiXml.parser | |
# => MultiXml::Parsers::Ox | |
MultiXml.parse(xml).keys | |
# => ["aws:UrlInfoResponse"] | |
MultiXml.parser = :rexml | |
# => :rexml | |
MultiXml.parse(xml).keys |
View layout_filter.rb
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
# Support for rendering views in layout | |
# Example usage in Assetfile: | |
# | |
# match "views/*.md" do | |
# markdown | |
# layout path: "app/views/layout.erb" | |
# concat { |input| input.sub(%r{views/}, "").sub(/\.md/, ".html") } | |
# end | |
require "rake-pipeline" |
View railscasts.rb
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
# Downloads PRO Railscasts | |
# Your private feed url can be found on https://railscasts.com/subscriptions/current | |
require "multi_xml" | |
require "open-uri" | |
PRIVATE_RSS_URL = "private-url" | |
PUBLIC_RSS_URL = "http://feeds.feedburner.com/railscasts" | |
private_feed = MultiXml.parse open(PRIVATE_RSS_URL) |
View deployer.rake
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
# Rake task to copy local files to remote server via FTP | |
# required credentials.yml file, that contains keys: | |
# server, username, password | |
require "net/ftp" | |
require "yaml" | |
class FTPClient | |
attr_reader :remote_path |
View gist:1486932
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
# Tested on Ubuntu 11.10 | |
# sudo apt-get install transmission-daemon | |
# Customize /etc/transmission-daemon/settings.json | |
{ | |
"alt-speed-down": 50, | |
"alt-speed-enabled": false, | |
"alt-speed-time-begin": 540, | |
"alt-speed-time-day": 127, | |
"alt-speed-time-enabled": false, | |
"alt-speed-time-end": 1020, |
View gist:1468756
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
# Configuring sound server | |
# Tested on Ubuntu 11.10 | |
sudo apt-get install pulseaudio-module-zeroconf | |
# Change /etc/default/pulseaudio file on server to contain: | |
PULSEAUDIO_SYSTEM_START=1 | |
DISALLOW_MODULE_LOADING=1 |
View gist:1162135
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
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: node_debian_init | |
# Required-Start: $remote_fs $named $syslog | |
# Required-Stop: $remote_fs $named $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: DEBIAN initscript for node.js servers/apps | |
# Description: ex : proxy server is a node.js http server listening on |
View gist:822127
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 respond_with(*resources, &block) | |
raise "In order to use respond_with, first you need to declare the formats your " << | |
"controller responds to in the class level" if self.class.mimes_for_respond_to.empty? | |
if response = retrieve_response_from_mimes(&block) | |
options = resources.size == 1 ? {} : resources.extract_options! | |
resources = resources.size == 1 ? Array.wrap(resources.first) : resources | |
options.merge!(:default_response => response) | |
(options.delete(:responder) || self.class.responder).call(self, resources, options) | |
end |
NewerOlder