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
# quick class to create seed data from an existing model | |
# http://intridea.com/2008/4/20/seed-fu-simple-seed-data-for-rails | |
# sd = MakeSeedData.new(MyActiveRecord) | |
# sd.generate # get all records | |
# sd.generate(MyActiveRecord.all(:conditions => ...)) | |
# | |
# Generate returns a string, put it in a file in db/fixtures as per their | |
# instructions. It can be passed any array of objects that can pretend to be | |
# the base active records | |
# |
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
alias gst='git status' | |
alias gl='git pull' | |
alias gp='git push' | |
alias gd='git diff | mate' | |
alias gc='git commit -v' | |
alias gca='git add . ;git commit -v' | |
alias gb='git branch' | |
alias gba='git branch -a' |
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 Paperclip | |
class Attachment | |
def url style = default_style, include_updated_timestamp = true | |
url = original_filename.nil? ? interpolate(@default_url, style) : interpolate(@url, style) | |
include_updated_timestamp && updated_at ? [url, updated_at].compact.join(url.include?("?") ? "&" : "?") : url | |
url.gsub(/s3\./,"s3-eu-west-1.") | |
end | |
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
# usage: | |
# generate_resource(Story) | |
# This generates the things you need to paste into data access | |
# classes when you're using the objective resource Objective C library | |
# http://iphoneonrails.com | |
# either save and load it or paste into a script/console session | |
def generate_resource(table) | |
cols = table.column_names.select { |c| !["created_at","updated_at"].include?(c)}.collect { |n| n.camelcase(:lower)} | |
theString = "" |
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
# Convert string of the form 2011-12-31T23:59:59+00:00 to a Ruby Time object | |
# I'm sure there's an easier way to do this. | |
def self.json_to_ruby_time(the_string) | |
string_elements = the_string.split /[-T:+]+/ | |
string_elements.pop | |
Time.new *(string_elements.map(&:to_i)) | |
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
package com.yourco.yourapp; | |
import java.util.ArrayList; | |
import java.util.List; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.BaseAdapter; |
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
[^[:alnum:]]ahole[^[:alnum:]] | |
[^[:alnum:]]anus[^[:alnum:]] | |
[^[:alnum:]]ash[0o]le[^[:alnum:]] | |
[^[:alnum:]]ass[^[:alnum:]] | |
[^[:alnum:]]azz[^[:alnum:]] | |
[^[:alnum:]]bassterd[^[:alnum:]] | |
[^[:alnum:]]bast[ae]+rd[^[:alnum:]] | |
[^[:alnum:]]b[i1]+[a]*tch[^[:alnum:]] | |
[^[:alnum:]]bl[o0]+wj[o0]+b[^[:alnum:]] | |
[^[:alnum:]]boffing[^[:alnum:]] |
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
# load this file to create a method that creates a capybara session you can play | |
# with in irb | |
require 'capybara' | |
require 'capybara/poltergeist' | |
require 'ext/capybara/session' | |
def session(driver = :poltergeist) | |
Capybara.register_driver :poltergeist do |app| |
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
#! /usr/bin/ruby | |
require 'date' | |
require 'set' | |
quotes = $<.readlines.map { |line| line.strip } | |
tag = "#unicorns" | |
url = "https://leanpub.com/unicorns" |
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 make_group col | |
<<-EOT | |
<div class="control-group"> | |
<%= form.label :#{col}, class: 'control-label' %> | |
<div class="controls"> | |
<%= form.text_field :#{col}, { class: 'input-xlarge' } %> | |
</div> | |
</div> | |
EOT | |
end |
OlderNewer