Skip to content

Instantly share code, notes, and snippets.

@tommi-lew
tommi-lew / .hound.yml
Created August 3, 2015 15:36
Hound CI Configs
ruby:
config_file: config/ruby-style.yml
javascript:
config_file: app/assets/javascripts/jshintrc
scss:
config_file: config/.scss-style.yml
StringLiterals:
@tommi-lew
tommi-lew / heroku_apps_libyaml_versions.rb
Last active August 29, 2015 13:58
Check libyaml version used by Psych gem
#!/usr/bin/env rvm-auto-ruby
heroku_apps = `heroku apps`
heroku_apps = heroku_apps.split("\n")
heroku_apps.shift
heroku_apps.map! {|item| item.split(" ")[0] }
heroku_apps.each do |app|
puts "#{app}: "
output = `heroku run "ruby -rpsych -e 'p Psych.libyaml_version.join(\\".\\")'" -a #{app}`
@tommi-lew
tommi-lew / test_csv.rb
Last active August 29, 2015 13:57
An example of how I test CSV generation
class Person < ActiveRecord::Base
#... some other methods ...
def self.export_as_csv
#... generates a CSV string ...
end
end
#spec
describe Person do
@tommi-lew
tommi-lew / gist:8093509
Created December 23, 2013 08:34
Get Heroku apps and output their ruby versions.
#!/usr/bin/env rvm-auto-ruby
heroku_apps = `heroku apps`
heroku_apps = heroku_apps.split("\n")
heroku_apps.shift
heroku_apps.map! {|item| item.split(" ")[0] }
heroku_apps.each do |app|
ruby_version = `heroku run "ruby -v" -a #{app}`
p "#{app}: #{ruby_version.split("\n")[1]}"
@tommi-lew
tommi-lew / gist:3033435
Created July 2, 2012 14:12
Gemfile for a new rails app
source :rubygems
gem 'rails' , '3.2.3'
gem "unicorn" , "~> 4.3.1"
gem "jquery-rails" , "~> 2.0.2"
gem "rake" , "~> 0.9.2.2"
gem "pg" , "~> 0.14.0"
group :development, :test do
gem "rspec-rails" , "~> 2.10.1"
@tommi-lew
tommi-lew / gist:3026421
Created July 1, 2012 01:33
Heroku commands
heroku config:add TZ=Asia/Hong_Kong
@tommi-lew
tommi-lew / Gemfile
Created June 29, 2012 15:41 — forked from robotarmy/Gemfile
Adding Rake to Sinatra with Rspec
gem 'sinatra'
group :development,:test do
gem 'rspec'
gem 'rack-test'
end
@tommi-lew
tommi-lew / log4j.properties
Created June 24, 2012 02:02
Java log4j.properties
log4j.rootLogger=debug, stdout, file
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
### file appender
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.maxFileSize=100KB
@tommi-lew
tommi-lew / gist:2960141
Created June 20, 2012 14:22
Code snippets on using PIL for overlaying text over image
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
from StringIO import StringIO
font = ImageFont.load_default()
input = StringIO(self.request.get("img"))
img = Image.open(input)
draw = ImageDraw.Draw(img)
@tommi-lew
tommi-lew / gist:2958404
Created June 20, 2012 06:14
Ruby SOAP Client
#Part of a school project using SAP ERP.
#Created a composite application using a Linux EC2 Instance & created SOAP web services.
#Used Ruby to invoke enterprises services in SAP.
require 'rubygems'
require 'savon'
client = Savon::Client.new do
wsdl.document = File.read("wsdl_document.wsdl")
http.auth.basic "username", "password"