Skip to content

Instantly share code, notes, and snippets.

View algogrit's full-sized avatar

Gaurav Agarwal algogrit

View GitHub Profile
@algogrit
algogrit / .irbrc
Created June 27, 2013 17:11 — forked from patmcnally/.irbrc
# load libraries
require 'rubygems' rescue nil
require 'wirble'
#require 'json'
alias q exit
class Object
def local_methods
(methods - Object.instance_methods).sort
# configuration for osx clipboard support
set-option -g default-command "reattach-to-user-namespace -l sh"
#!/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

Ruby 2.0.0 in detail

Keyword arguments

def wrap(string, before: "<", after: ">")
  "#{before}#{string}#{after}" # no need to retrieve options from a hash
end

# optional

wrap("foo") #=> ""