Skip to content

Instantly share code, notes, and snippets.

@Phazz
Phazz / tmux-cheatsheet.markdown
Created January 26, 2018 06:02 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@Phazz
Phazz / 01-safe-download.rb
Created April 19, 2017 08:18 — forked from janko/01-safe-download.rb
A safe way in Ruby to download a file to disk using open-uri (with/without comments)
require "open-uri"
require "net/http"
Error = Class.new(StandardError)
DOWNLOAD_ERRORS = [
SocketError,
OpenURI::HTTPError,
RuntimeError,
URI::InvalidURIError,
@Phazz
Phazz / install consolas on os x with one command
Last active July 16, 2016 05:37 — forked from piperswe/ install consolas on os x with one command
Install Consolas on OS X (based on avalonalex/8125197)
Thanks to this Gist: https://gist.github.com/avalonalex/8125197
How to use: Make sure Homebrew is installed then run `curl https://gist.githubusercontent.com/zebMcCorkle/fa4508e27f457d7b796ffd474be35d62/raw/59942466b13fe92d09b4b537cc7fcfb309c05c4a/consolas.sh | bash -`
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
@Phazz
Phazz / pr.md
Last active August 29, 2015 14:10 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@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>