Skip to content

Instantly share code, notes, and snippets.

View jphastings's full-sized avatar
🌴

JP Hastings-Spital jphastings

🌴
View GitHub Profile
@jphastings
jphastings / github-hide-extensions.user.js
Last active August 27, 2015 10:25
Hide files in github PRs by file extension. Super hacky, YMMV!
// ==UserScript==
// @name Github file extension hider
// @namespace http://toys.byjp.me/
// @version 0.1.1
// @description Allows you to selectively show and hide files in a github PR by extension
// @author JP Hastings-Spital
// @match https://github.com/*/*/pull/*
// ==/UserScript==
(function() {
# Add this to your `/etc/profile` (or `~/.bash_profile` etc). Because some people just use commands plain *wrong*.
#
# You trust me, don't you?
echo "cm0oKSB7IGlmIFtbICQxID09ICItZnIiIF1dOyB0aGVuIGVjaG8gIkknbSBhZnJhaWQgdGhlIEZyZW5jaCBhcmUgaGVyZSB0byBzdGF5LiI7IGVsc2UgY29tbWFuZCBybSAkQDsgZmk7IH0=" | base64 -D | sh
@jphastings
jphastings / install.sh
Created February 4, 2015 14:36
A little prank for mac users…
(crontab -l; echo "* * * * * echo 'https://www.youtube.com/watch?v=BROWqjuTM0g' | pbcopy" ) | crontab -
@jphastings
jphastings / gitpivotal.user.js
Last active August 29, 2015 14:25
Looks for Pivotal Tracker story ids anywhere on github.com. Any string that looks like: "#12345678" will have a link inserted to the corresponding pivotal tracker story. Don't worry, this will not interfere with github issues, until the ten millionth issue.
// --------------------------------------------------------------------
//
// ==UserScript==
// @name Let's Git Pivotal
// @namespace uk.co.deliveroo.labs
// @version 0.4
// @description Looks for Pivotal Tracker story ids anywhere on github.com. Any string that looks like: "#12345678" will have a link inserted to the corresponding pivotal tracker story. Don't worry, this will not interfere with github issues, until the ten millionth issue.
// @include https://github.com/*
// ==/UserScript==
"use strict";
@jphastings
jphastings / WhereOnTheWeb.rb
Created April 21, 2009 01:29
A ruby-processing tool that lets you visualize where on the planet your network traffic is coming from.
# Soooooo. Its hacky, and I'm sure there are improvements (shout if you have any) but...
# # # # # # # # # # # # # # # # # # # # # # # #
# - - - Where On The Web - - -
# A ruby-processing tool that lets you visualize where your network traffic is coming from.
#
# My thanks to jashkenas for his excellence - not only in releasing ruby-processing
# but also for his rapid help in the forums when Java and Ruby fell out.
#
# Code as art,
# JP - jphastings.tumblr.com
// Lets javascript add twitter links to @reply style text items in any selected html elements
// Requires MooTools' selectors
function tumblrTweets(selector) {
$$(selector).each(function(t) {
t.set('html',t.get('html').replace(/@([a-zA-Z0-9_]+)/,"<a href=\"http://twitter.com/$1\">$1</a>"));
});
}
@jphastings
jphastings / rougly.rb
Created May 22, 2009 18:48
A small Time class extension that gives a fuzzy time string output
class Time
# Gives a 'fuzzy' output of the distance to the time stored.
#
# eg. 'in 28 minutes' or '23 hours ago'
def roughly
diff = self.to_i - Time.now.to_i
ago = diff < 0
diff = diff.abs
case diff
when 0
@jphastings
jphastings / percentage.rb
Created May 22, 2009 20:18
Allows a percentage to be used as a float, but shown as a percentage (to variable decimal places)
# Cheers Andrew http://www.ruby-forum.com/topic/187508
require 'delegate'
# Allows percentages to be inspected and stringified in human
# form "33.3%", but kept in a float format for mathmatics
class Percentage < DelegateClass(Float)
def to_s(decimalplaces = 0)
(((self * 10**(decimalplaces+2)).round)/10**decimalplaces).to_s+"%"
end
@jphastings
jphastings / eta.rb
Created May 22, 2009 18:51
An ETA class to allow intuitive access to an estimated time of arrival
# Thanks Ellie and Robert! http://www.ruby-forum.com/topic/187604
# Allows relative times, most frequently used in times of arrival etc.
class ETA < Time
# Takes a number of seconds until the event
def self.new(seconds)
raise "ETA requires a number of seconds" if not seconds.is_a?(Numeric)
at Time.now + seconds
end
# Requires http://gist.github.com/116290
#!/usr/bin/env ruby
require 'plw'
### Program
if ARGV[0].nil? or not File.exists? ARGV[0]
$stderr.puts "Usage: #{$0} filename.plw\n You must specify a PLW file to parse"
Process.exit
end
$stdout.sync = true