Skip to content

Instantly share code, notes, and snippets.

View wr0ngway's full-sized avatar

Matt Conway wr0ngway

View GitHub Profile
@wr0ngway
wr0ngway / gist-bundler.rb
Created February 8, 2012 15:53
Using gist to achieve self contained bundled gems within a single ruby script
require 'tmpdir'
require 'fileutils'
# scope bundling for this script to a directory based on its path
tmpdir = "#{Dir.tmpdir}/script_bundler/#{File.expand_path(__FILE__).gsub(/\W+/, '_')}"
FileUtils.mkdir_p(tmpdir)
gemfile = "#{tmpdir}/Gemfile"
gemfile_lock = "#{gemfile}.lock"
@wr0ngway
wr0ngway / gist-util.rb
Created February 8, 2012 16:11
Utility script to archive and cleanup old gists
#!/usr/bin/env ruby
# Add your gems here
#
gemfile_contents = <<-EOF
source "http://rubygems.org"
gem 'clamp'
gem 'iniparse'
gem 'rest-client'
gem 'json'
@wr0ngway
wr0ngway / gc-cow.rb
Created March 23, 2012 17:46
test to see if GC in ruby 2 is truly copy on write friendly
#!/usr/bin/env ruby
rss = '.+?Rss:\s+(\d+)'
share = '.+?Shared_Clean:\s+(\d+)'
share << '.+?Shared_Dirty:\s+(\d+)'
priv = '.+?Private_Clean:\s+(\d+)'
priv << '.+?Private_Dirty:\s+(\d+)'
MEM_REGEXP = /\[heap\]#{rss}#{share}#{priv}/m
def mem_usage_linux
@wr0ngway
wr0ngway / changelog
Last active August 29, 2015 13:57
For generating changelogs for bundler rubygem projects
#!/usr/bin/env ruby
require 'bundler'
changelog_file = 'CHANGELOG'
entries = ""
helper = Bundler::GemHelper.new(Dir.pwd)
current_version = "v#{helper.gemspec.version}"
starting_version = nil
@wr0ngway
wr0ngway / bundlelocal
Created July 11, 2014 11:03
Wrapper to bundle that lets one temporarily point to local directories for gems (works better with rubymine than bundle local)
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
raise "Pass in local gems like: LOCAL_GEMS=foo,bar bundle ..." unless ENV['LOCAL_GEMS']
LOCAL_GEMS = ENV['LOCAL_GEMS'].split(',')
class Bundler::Dsl