Skip to content

Instantly share code, notes, and snippets.

@zetter
zetter / atom.rb
Last active August 29, 2015 13:56 — forked from floehopper/atom.rb
class Atom
attr_reader :symbol
def initialize(symbol)
@symbol = symbol
end
def ==(other)
self.symbol == other.symbol
end
@zetter
zetter / phantomjs
Last active January 3, 2016 08:49
Filter out userSpaceScaleFactor warning on phantomjs on Mavericks
#!/bin/bash
/usr/local/bin/phantomjs_original $@ 2> >(grep -v userSpaceScaleFactor 1>&2)
@zetter
zetter / parse_icons_from_icomoon.rb
Created December 9, 2013 15:54
Parse the icon file from icomoon and print out a ruby hash of character names to characters.
# Usage:
# run the file with the dev.svg from icomoon (not the plain svg)
# ruby parse_icons_from_icomoon.rb /path/to/iconfont.dev.svg
require 'nokogiri'
file = ARGV[0]
svg = File.open(file)
document = Nokogiri::XML(svg)
@zetter
zetter / transaction_download.applescript
Last active December 27, 2015 20:49
Halifax Online Banking Transaction Downloader Applescript
(*
Halifax Online Banking Transaction Downloader Applescript
https://gist.github.com/zetter/7387018
To use:
+ Set the path to an existing directory where you want to save the
pages.
+ Open Safari with a single window and tab and login to Halifax Online.
+ Load up the first page of the transactions for the account you want to save.
+ Run this script.
@zetter
zetter / find_git_remote_branches.sh
Created October 31, 2013 09:51
List the remote branches that with a last commit that you authored.
# list remote branches with committer name and email
function git_remote_branches_with_author {
for branch in `git branch -r | grep -v /HEAD`; do
echo -en "$branch ";
echo -e `git show -s --pretty=format:"%an %ae" $branch`;
done
}
# show filtered remote branches
function find_git_remote_branches {
@zetter
zetter / gist:7133549
Last active December 26, 2015 09:59 — forked from ericboehs/gist:7125105
Fix to work with current version of poltergeist. Don't recommend using.
module Capybara::Poltergeist
class Client
def redirect_stdout
prev_stdout = STDOUT.dup
prev_stderror = STDERR.dup
prev_stdout.autoclose = false
$stdout = @write_io
STDOUT.reopen(@write_io)
@zetter
zetter / gist:7133394
Last active December 26, 2015 09:59
Textmate Mavericks annocement

Dear Sir/Madam,

Forgive me for this unsolicited (one time) service announcement.

I am writing because you have a TextMate license. If you wish to update to OS X 10.9 (Mavericks) and are still using TextMate 1.x then you should be aware that some bundle items will fail due to ruby 2.0 now being the default.

Our recommended fix is to upgrade to TextMate 2.0, which is a free¹ update and can be downloaded from https://macromates.com/download — the reason we still label it alpha is mainly because the manual is incomplete.

The preliminary manual is at http://manual.textmate.org/ and we have a dozen or so blog posts about 2.0 features at https://macromates.com/blog/categories/textmate-2/ but you can also email the mailing list or contact support with any questions, see https://macromates.com/contact.

@zetter
zetter / gist:7133389
Last active December 26, 2015 09:59
Rails development on OSX Mavericks

Do:

  • Install mavericks
  • Reinstall Command line tools[1] or Xcode (you may have problems using git and other tools even if they are already installed before you do this)
  • run brew update

Known problems:

Textmate

Texmate 1 won't work very well with the updated system ruby. You should use a recent Textmate 2 alpha.

PhantomJS

@zetter
zetter / frozen_string.rb
Created September 10, 2013 09:22
Sytax for declaring frozen strings
class String
def -@
self.freeze
end
end
#> x = -"abc" #=> "abc"
#> x[1] = 'd'
# RuntimeError: can't modify frozen String
@zetter
zetter / top_language_golf.rb
Created July 31, 2013 08:11
Code Golf. Get the top language from a users github profile. Run with the username, e.g. 'ruby top_language_golf.rb zetter'
require 'open-uri';puts open("https://github.com/"+ARGV[0]).read[/dd\>([^,]*)/,1]