🧘♂️
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
# Flatten a transparent image with a white background: | |
convert -flatten img1.png img1-white.png | |
# Make an image transparent | |
convert -transparent '#FFFFFF' nontransparent.gif transparent.png | |
# convert an image into tiles | |
convert -size 3200x3200 tile:single_tile.png final.png | |
# making a montage from a collection of images |
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/omniauth-adwords-oauth2.rb | |
require "omniauth-google-oauth2" | |
class AdwordsOauth2 < OmniAuth::Strategies::GoogleOauth2 | |
option :name, 'adwords_oauth2' | |
end | |
# config/initializers/omniauth.rb | |
require "omniauth-adwords-oauth2" |
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
var system = require('system'); | |
if (system.args.length < 5) { | |
console.info("You need to pass in account name, username, password, and path to casperJS as arguments to this code."); | |
phantom.exit(); | |
} | |
var account = system.args[1]; | |
var username = system.args[2]; | |
var password = system.args[3]; |
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
# BEGINNER: how to get started with ruby | |
# http://www.rubystudyhall.com/getting_started_with_ruby | |
# http://tryruby.org | |
# irb | |
# run "Hello, World" from command line | |
# do simple calculations | |
# read a file and count the lines in it | |
# read a file from command line argument |
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
# I run this command once a week on all of my active projects | |
# It helps ensure that I'm always able to use the latest/greatest | |
# versions of various dependencies, or at least that I find out | |
# quickly when I've become locked into a particular version | |
# (which just happened with the latest versions of the Ruby gems | |
# Webmock and VCR | |
alias mrupd='git pull && bundle update && rdbm && rspec spec; sd' | |
# the alias stands for 'massive rails update' because I have a bunch of other aliases that |
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
# Two of the projects we'll be discussing are heavily dependent on code like the example below, which | |
# requests stock price information from Google's finance API and transforms the results into a hash | |
# for use in our database. This pattern shows up over and over in my projects. I always setup a separate | |
# codebase containing a bunch of worker" modules that just do stuff like this. | |
# | |
# I need to write a bunch more of these for a variety of data sources. My plan is to start you off | |
# on these, then graduate to more complex features. | |
# | |
# Here are two things for you to try: | |
# |
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
# As soon as I create a Rails migration I always want to open that file in an editor. | |
# I'd like to submit the following patch to Rails to create an --editor argument | |
# for the migration generator but I can't quite figure out the Thor way of doing this. | |
require 'rails/generators/active_record' | |
module ActiveRecord | |
module Generators | |
class MigrationGenerator < Base | |
argument :editor, :type => :string, :lazy_default => ENV['EDITOR'], :required => false, :banner => "/path/to/your/editor", :desc => "Open migration using specified editor (defaults to EDITOR)" |
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
# http://stackoverflow.com/questions/1960799/using-gitdropbox-together-effectively/1961515#1961515 | |
export REPONAME=???? | |
take ~/Dropbox/git/$REPONAME.git | |
git init --bare | |
cd ~/code/$REPONAME | |
git remote rm origin | |
git remote add origin ~/Dropbox/git/$REPONAME.git | |
git push -u origin master |
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
html = IO.read("survey.html") | |
rows = Nokogiri::HTML(html).css("tr")[????].collect { |r| r.children.to_a.values_at(0,3).collect(&:content) }.sort_by(&:last).reverse.collect { |r| "#{r.first} - #{r.last}" } |