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
| namespace :svn do | |
| desc "Subversion: mark any new files as added" | |
| task :add do | |
| system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add" | |
| end | |
| 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
| <?php | |
| // Based upon http://goo.gl/406o | |
| class CliColor | |
| { | |
| private $foreground_colors = array(); | |
| private $background_colors = array(); | |
| public function __construct() | |
| { | |
| // Set up shell colors |
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
| namespace :mysql do | |
| task :clone_dev_db do | |
| require 'ostruct' | |
| db_config = OpenStruct.new(YAML.load_file("config/database.yml")) | |
| dev_db = db_config.development | |
| stage_db = db_config.send(stage) | |
| cmd = "mysqldump -u #{dev_db['username']} -h #{dev_db['host']} -p'#{dev_db['password']}' #{dev_db['database']} " + | |
| "--add-drop-table | mysql -u #{stage_db['username']} -p'#{stage_db['password']}' -h #{stage_db['host']} #{stage_db['database']}" | |
| run cmd | |
| 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
| NameVirtualHost *:80 | |
| <VirtualHost *:80> | |
| VirtualDocumentRoot "/Users/my.name/sandbox/%1" | |
| </VirtualHost> |
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
| <?php | |
| class ArrayExtensions | |
| { | |
| public function to_sentence($array) | |
| { | |
| $count = count($array); | |
| switch ($count) | |
| { | |
| case 0: |
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
| <?php | |
| // Output P3P header so that cookies are accessible to Facebook canvas iframe in IE | |
| $p3p_header = 'policyref="/w3c/p3p.xml", CP="NOI DSP COR CURa ADMa DEVa PSAa PSDa OUR NOR UNI COM NAV"'; | |
| $this->output->set_header('P3P: '.$p3p_header); |
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
| # When you switch SVN branches for deployment, Capistrano doesn't detect the change and | |
| # simply does an 'svn up' on whatever branch you had previously deployed. | |
| # This task checks if the cached copy's SVN URL matches the SVN URL you're deploying, | |
| # and removes the cached copy if it doesn't match | |
| namespace :cached_copy do | |
| task :check do | |
| cached_copy_path = "#{shared_path}/cached-copy" | |
| # Does the cached copy exist? | |
| cached_copy_exists = capture("if [ -d '#{cached_copy_path}' ]; then echo '1'; fi") |
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
| require 'rubygems' | |
| require 'json' | |
| require 'net/http' | |
| require 'cgi' | |
| twitter_user = 'agencyrepublic' | |
| url = "http://twitter.com/statuses/user_timeline/#{twitter_user}.json?count=200&include_rts=1" | |
| resp = Net::HTTP.get_response(URI.parse(url)) | |
| results = JSON.parse(resp.body) |
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
| SELECT pid, src_big | |
| FROM photo | |
| WHERE pid IN( | |
| SELECT pid | |
| FROM photo_tag | |
| WHERE subject = me() | |
| ) |
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
| SELECT pid, src_big | |
| FROM photo | |
| WHERE pid IN( | |
| SELECT pid | |
| FROM photo_tag | |
| WHERE subject = me() | |
| ) | |
| AND pid IN( | |
| SELECT pid | |
| FROM photo_tag |
OlderNewer