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
#app/models/parent.rb | |
class Parent < ActiveRecord::Base | |
accepts_nested_attributes_for :children | |
validate :children_are_less_than_two | |
private | |
def children_are_less_than_two | |
errors.add(:base, | |
"shouldn't have more than two children" | |
) if children.count > 2 |
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
I18n.extend Module.new { | |
def translate(*args) | |
print args.to_yaml | |
super | |
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 Tester | |
def Tester.hello | |
print 'hello' | |
end | |
extend Module.new { | |
def world | |
print 'world' | |
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
function rmb { | |
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') | |
if [ "$current_branch" != "master" ]; then | |
echo "WARNING: You are on branch $current_branch, NOT master." | |
fi | |
echo "Fetching merged branches..." | |
git remote prune origin | |
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$") | |
local_branches=$(git branch --merged | grep -v 'master$' | grep -v "$current_branch$") | |
if [ -z "$remote_branches" ] && [ -z "$local_branches" ]; then |
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 | |
# Script for installing optware on DD-WRT | |
# Written by frater | |
# | |
export PATH=/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin | |
SCRIPTVER="Fri Apr 22 17:08:38 CEST 2011" | |
export SITES='http://ipkg.nslu2-linux.org http://ftp-osl.osuosl.org/pub/nslu2' | |
export dom=wd.mirmana.com |
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
{ "run_list": "role[data_provider]" } |
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
101 def parse_and_update(file_name)$ | |
102 Rails.logger.info "============================== Parsing: #{file_name} Begin =============================="$ | |
103 piper, pipew = IO.pipe$ | |
104 Thread.new do$ | |
105 begin$ | |
106 @remote_archive.get(file_name) do |chunk|$ | |
107 puts chunk$ | |
108 pipew << chunk$ | |
109 end$ | |
110 rescue Exception => e$ |
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/bash | |
# node.js using PPA (for statsd) | |
sudo apt-get install python-software-properties -y | |
sudo apt-add-repository ppa:chris-lea/node.js | |
sudo apt-get update | |
sudo apt-get install nodejs npm -y | |
# Install git to get statsd | |
sudo apt-get install git -y |
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
# lib/redis_record/base.rb | |
module RedisRecord::Base | |
extend ActiveSupport::Concern | |
def save | |
run_callbacks :save do | |
success = REDIS.multi do | |
REDIS.mapped_hmset(key, attributes) | |
sorted_indices.each do |attr| |
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
Fion.deleteItem = function (contentName) { | |
var asin = contentName.substring(11); // asin extracted from the argument | |
var itemData = itemCache.getDataByASIN(asin); // the item in the library list | |
// create vars to be sent in the ajax request to fiona-delete | |
var lendingId = ''; | |
var lendingType = ''; | |
var lendingStatus = ''; | |
var loanId = ''; | |
// assign the above vars where appropriate | |
if (itemData.loanId) { |
OlderNewer