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/env ruby | |
require 'optparse' | |
require 'ostruct' | |
options = OpenStruct.new | |
options.rows = 10 | |
options.columns = 10 | |
OptionParser.new do |opts| | |
opts.on('-r', '--rows [INTEGER]', 'Number of rows', Integer) do |x| |
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
namespace :heroku do | |
desc "Push current branch to Heroku master" | |
task :push do | |
current_git_branch = %x(git branch).split("\n").select { |line| line =~ /^\* / }.map { |line| line[2..-1] }[0] | |
puts "Pushing branch #{current_git_branch} to Heroku" | |
%x(git push heroku #{current_git_branch}:master) | |
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
namespace :haml do | |
# Monitor the current directory looking for changes to Haml source files and | |
# compile on updates. Defaults to watching the current directory. You can | |
# override by specifying another directory in square brackets immediately | |
# after the watch target, e.g. | |
# | |
# rake haml:watch[/tmp] | |
# | |
# Note, you need the FSSM gem installing, i.e. gem install fssm. Of course, | |
# you also need Haml itself. |
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
namespace :db do | |
namespace :fixtures do | |
desc "Write YAML-formatted test fixtures using current database" | |
task :write_yml, [:limit] => [:environment] do |t, args| | |
args.with_defaults(:limit => nil) | |
write_active_record_tables('.yml', args.limit) do |output_stream, records| | |
# Important not to write the records as an array; write them as a hash. | |
# Use the "id" as the unique hash key. This formats the fixture in | |
# standard unordered layout. | |
hash = {} |
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
/*! | |
* Replaces all matches of a given regular expression in a given string using a | |
* given block to compute the replacement string for each match. The block | |
* accepts the match result, the progressively replaced string along with its | |
* progressive offset. | |
*/ | |
NSString *RRReplaceRegularExpressionMatchesInString(NSRegularExpression *regex, NSString *string, NSString *(^replacementStringForResult)(NSTextCheckingResult *result, NSString *inString, NSInteger offset)) | |
{ | |
NSMutableString *mutableString = [string mutableCopy]; | |
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
// Define NS_NONATOMIC_IOSONLY here for now if not already defined. This is | |
// necessary during the transition between iOS 4.3 and iOS 5.0. Lion already | |
// defines NS_NONATOMIC_IOSONLY but iOS 4.3 does not. Instead it defines | |
// NS_NONATOMIC_IPHONEONLY; the phone has become the OS! | |
#if !defined(NS_NONATOMIC_IOSONLY) | |
#if TARGET_OS_IPHONE | |
#define NS_NONATOMIC_IOSONLY nonatomic | |
#else | |
#define NS_NONATOMIC_IOSONLY | |
#endif |
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
namespace :assets do | |
desc "Lists asset paths" | |
task :paths => :environment do | |
Rails.application.config.assets.paths.each do |path| | |
puts path | |
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
namespace :pg do | |
namespace :structure do | |
# Does exactly the same as db:structure:dump but with one important | |
# difference. It tries to use a compatible version of pg_dump. If you see | |
# the following error message, use pg:structure:dump instead. | |
# | |
# pg_dump: server version: 9.1.0; pg_dump version: 9.0.4 | |
# pg_dump: aborting because of server version mismatch | |
# rake aborted! | |
# Error dumping database |
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
#define DIMOF(array) (sizeof(array)/sizeof((array)[0])) |
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
# PostgreSQL. Versions 8.2 and up are supported. | |
# | |
# Install the pg driver: | |
# gem install pg | |
# On Mac OS X with macports: | |
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config | |
# On Windows: | |
# gem install pg | |
# Choose the win32 build. | |
# Install PostgreSQL and put its /bin directory on your path. |
OlderNewer