This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in a git repo, compare your branch to another branch on github.com | |
# and optionally create a pull request | |
function gpr { | |
local repo | |
local branch | |
local title | |
repo=$(git ls-remote --get-url 2>/dev/null) | |
branch=$(git branch --no-color --contains HEAD 2>/dev/null | awk '{ print $2 }') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# brew install httpie pup recode | |
# usage: git commit -m "$(excuse.sh)" | |
http http://programmingexcuses.com/ | pup 'center a text{}' | recode html..ascii |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this should be added to or loaded by your .bashrc | |
# usage: gh | |
# gh <repo_name> | |
# gh <user>/<repo_name> | |
function gh { | |
repo="$1" | |
if [ -z "$repo" ]; then | |
# if no argument provided, then get the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline_svg_images = (svg) -> | |
svg_selector = if svg? and $(svg)? then svg else 'img.svg' | |
$(svg_selector).each -> | |
$img = $(@) | |
$.get $img.attr('src'), (data) -> | |
$svg = $(data).find 'svg' | |
for attribute in [ 'id', 'class', 'height', 'width' ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
numbers = [2, 6, 4, 8, 8, 9] | |
sum = ARGV.empty? ? 10 : ARGV.first.to_i | |
def sum_exists(numbers, sum) | |
Array(numbers).combination(2).find_all { |x, y| x + y == sum } || [] | |
end | |
result = sum_exists(numbers, sum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# usage: saveimages.rb <url> | |
# locally save all images from a web site | |
require 'nokogiri' | |
require 'open-uri' | |
exit if ARGV[0].nil? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var host = process.argv[2] || '127.0.0.1'; | |
var port = process.argv[3] || 8080; | |
http.createServer( function (req, res) { | |
var proxy = http.request(req.url, function (proxy_res) { | |
proxy_res.on('data', function (chunk) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# forget.sh: remove matching lines from ~/.ssh/known_hosts | |
# usage: forget <hostname|IP|substring> [...] | |
function forget { | |
known_hosts=~/.ssh/known_hosts | |
for host in $* | |
do | |
host=$(echo "${host}" | sed -e 's/^ssh:\/\///' -e 's/^.*@//') | |
line=$(awk '{ print $1 }' ${known_hosts} | grep -n "${host}" | sed 's/:.*$//g' | xargs) | |
while [ -n "${line}" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to run: | |
# 1. npm install -g coffee-script | |
# 2. npm install http-proxy | |
# 3. coffee kittenproxy.coffee | |
# 4. change browser proxy settings to <thishost>:8080 | |
httpProxy = require("http-proxy") | |
address = process.argv[2] or "0.0.0.0" | |
port = process.argv[3] or 8080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dgram = require('dgram'); | |
var host = process.argv[2] || '0.0.0.0'; | |
var port = process.argv[3] || 514; | |
var server = dgram.createSocket('udp4'); | |
server.on('message', function(msg, rinfo) { | |
console.log("received: %s from %s:%s", msg, rinfo.address, rinfo.port); | |
}); |