Skip to content

Instantly share code, notes, and snippets.

View jphastings's full-sized avatar
🌴

JP Hastings-Spital jphastings

🌴
View GitHub Profile
@jphastings
jphastings / README.md
Last active October 19, 2015 12:54
Simplify ZenHub
@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() {
@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 / 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 -
# 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
FROM custom/ruby
ADD . /src
WORKDIR /src
# NB. I'm installing ruby with RVM, so I have to run these commands via bash to get rvm to start up
RUN /bin/bash -lc bundle install --deployment --path ./vendor
EXPOSE 80
ENTRYPOINT ["/bin/bash", "-lc", "bundle exec ruby serve.rb"]
@jphastings
jphastings / _Readme.md
Last active December 14, 2015 09:38
Adds CSS to a page via JavaScript

This function will add CSS to an entire page.

addGlobalCss(".item { display:none; }",'toggle_id')

Will hide all elements with the 'item' class but, unlike $('.item').hide() it will also ensure any elements with that class that are subsequently added to the page will also be hidden.

The reference_id is used as the id of the tag added, meaning that a second call to this function with the same reference_id will remove the previous CSS.

@jphastings
jphastings / rail.voronoi.kml
Created November 19, 2012 23:23
Voronoi London Rail Maps
<!--
A voronoi map of London Rail transport (includes overground, trains etc.)
Paste this into http://display-kml.appspot.com/ for a map!
-->
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
@jphastings
jphastings / jsonp_helper.rb
Created September 17, 2012 16:49
JSONP helper for active record
# Now when you do `User.to_json(:jsonp => 'method')` you will get `method({id:1,username:'jphastings'})`
#
# Needs some sanitization of the javascript method name to prevent nastiness.
module ActiveSupport
# == Active Model JSON Serializer
module JSON
def self.encode(value,options = {})
if options.has_key?(:jsonp)
method_name = options.delete :jsonp
@jphastings
jphastings / 1. proposal.md
Created September 23, 2011 04:30
Proposal for sinatra 'view routes'

Sinatra View Routes

View routes would allow people to define different views for different devices without using any logic.

Anyone got any thoughts?