Skip to content

Instantly share code, notes, and snippets.

@Phazz
Phazz / to_csv.rb
Last active August 29, 2015 14:07 — forked from amir20/to_csv.rb
#!/usr/bin/ruby
if ARGV.size.zero?
puts %Q[
Usage:
./to_csv.rb file.yml > out.csv
]
exit
end
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@Phazz
Phazz / gist:e368cb8518269e0ca09e
Last active August 29, 2015 14:03 — forked from schacon/gist:942899
Delete merged branch in origin not named master, develop or release
$ git remote prune origin && git branch -r --merged |
grep origin |
grep -v '>' |
grep -v 'master' |
grep -v 'release' |
grep -v 'develop' |
xargs -L1 |
cut -d"/" -f 2 |
xargs git push origin --delete
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="jquery.tipsy.js"></script>
<link href="tipsy.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="chart"></div>

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@Phazz
Phazz / measure.rb
Created January 28, 2014 05:49 — forked from camertron/measure.rb
#!/bin/env ruby
# lazy hack from Robert Klemme
module Memory
# sizes are guessed, I was too lazy to look
# them up and then they are also platform
# dependent
REF_SIZE = 4 # ?
OBJ_OVERHEAD = 4 # ?
@Phazz
Phazz / gist:8662773
Created January 28, 2014 05:37 — forked from fl00r/gist:7542994
class TrieDict
attr_reader :dict
def initialize
@dict = {}
end
def put(str)
d = nil
str.chars.each do |c|
require 'benchmark'
#
# Code example for my blogpost
#
# Hash lookup in Ruby, why is it so fast?
#
#
# Struct used to store Hash Entries
@Phazz
Phazz / gist:8314399
Created January 8, 2014 10:00
Poor's man memory profiler
# call this to get the memory size of the process before and after a treatment
def memstats
size = `ps -o size= #{$$}`.strip.to_i
end
test:
override:
- bundle exec rspec spec
deployment:
acceptance:
branch: master
commands:
- ./script/heroku_deploy.sh <ACCEPTANCE_HEROKU_APP>:
timeout: 300