Skip to content

Instantly share code, notes, and snippets.

@andrewculver
andrewculver / fixing_x000a.rb
Created April 20, 2012 00:59
Temporary fix for the extra newline (
) Rails 3.2.3 + Haml are adding to the output of the text_area form helper.
module ActionView
module Helpers
module FormHelper
def text_area(object_name, method, options = {})
html = InstanceTag.new(object_name, method, self, options.delete(:object)).to_text_area_tag(options)
html.gsub(/>\
/, '>').html_safe
end
end
end
end
@sapient
sapient / xirr.rb
Created November 14, 2011 20:07
XIRR Function Written for Ruby 1.9.2
require 'date'
require 'bigdecimal/newton'
require 'bigdecimal/math'
include Newton
class XIRR
def initialize(datevalues)
@datevalues = datevalues
@zero = BigDecimal::new("0.0")
@mjwall
mjwall / screen.rb
Created October 14, 2011 14:05
Homebrew screen install with 256 colors and vertical splits
require 'formula'
class Screen <Formula
homepage 'http://www.gnu.org/software/screen/'
url 'http://ftp.gnu.org/gnu/screen/screen-4.0.3.tar.gz'
md5 '8506fd205028a96c741e4037de6e3c42'
# brew install --HEAD to get the latests, includes vertical split, mapped
# to C-a |
head 'git://git.savannah.gnu.org/screen.git', :branch => 'master'
@seymores
seymores / androidmanifest_decompressor.groovy
Created May 24, 2011 07:19
AndroidManifest.xml decompressor
// decompressXML -- Parse the 'compressed' binary form of Android XML docs
// such as for AndroidManifest.xml in .apk files
int endDocTag = 0x00100101;
int startTag = 0x00100102;
int endTag = 0x00100103;
public void decompressXML(byte[] xml) {
// Compressed XML file/bytes starts with 24x bytes of data,
// 9 32 bit words in little endian order (LSB first):
// 0th word is 03 00 08 00
@njvitto
njvitto / deploy.rake
Created April 11, 2010 16:56 — forked from RSpace/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]