Skip to content

Instantly share code, notes, and snippets.

View joshprice's full-sized avatar
⚗️
Alembic is hiring!

Josh Price joshprice

⚗️
Alembic is hiring!
View GitHub Profile
### Keybase proof
I hereby claim:
* I am joshprice on github.
* I am joshprice (https://keybase.io/joshprice) on keybase.
* I have a public key whose fingerprint is 08EA 0ACE 6A62 A852 259B 743C 6749 8211 1E02 CE56
To claim this, I am signing this object:
@joshprice
joshprice / array.rb
Created November 13, 2010 02:38
Array#to_hash (why doesn't this exist already?)
class Array
def to_hash
Hash[self]
end
end
⚡ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
data/.TAGS.i@417: missing revlog!
417: empty or missing .TAGS
.TAGS@417: 64e9244a76f6 in manifests not found
.TAGS@442: 28d1b1b79d61 in manifests not found
.TAGS@443: 4a5a2e285db3 in manifests not found
@joshprice
joshprice / josh.zsh-theme
Created July 13, 2010 14:46 — forked from pat/pat.zsh-theme
Pat's theme but minus the time, home as ~ and on one line (and particularly hardcoded to my setup tsk tsk)
grey='\e[0;90m'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$grey%}("
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$grey%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$grey%})"
function pat_prompt {
(( spare_width = ${COLUMNS} ))
prompt=" "
helpers do
def mobile_request?
[ /AppleWebKit.*Mobile/, /Android.*AppleWebKit/ ].any? {|r| request.env['HTTP_USER_AGENT'] =~ r}
end
def mobile_file(name)
File.exist?("#{options.views}/#{name}#{@mobile}.haml") ? :"#{name}#{@mobile}" : name.to_sym
end
def partial(name)
haml mobile_file("_#{name}"), :layout => false
end
@joshprice
joshprice / IE6 and 7 header float bug [FIXED]
Created October 22, 2009 05:35
zoom:1 is a hack for IE to recognise floating children and we use a margin-top of -1em to realign
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
.wrapper { border: 1px solid black; }
.wrapper h3 a { float: right; }
</style>
<!--[if lte IE 7]>
<style>
@joshprice
joshprice / jQuerify bookmarklet
Created October 3, 2009 01:49
jQuerify a webpage so you can interact with it using jQuery. Save as a bookmark with the contents as the URL. There's a Firebug plugin to do this, but this works in more browsers.
javascript:(function(){var%20j=document.createElement('script');j.setAttribute('type','text/javascript');j.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js');document.body.appendChild(j);})();
@joshprice
joshprice / MultiplexingProxy.rb
Created August 1, 2009 05:45
Multiplexing Proxy
require "rubygems"
require "webrick/httpproxy"
module WEBrick
class HTTPRequest
attr_writer :host, :port, :request_uri, :unparsed_uri, :request_line, :path
end
end
class MultiplexingProxy < WEBrick::HTTPProxyServer
(function() {
var controlPanel = (<r><![CDATA[
<div id='controlpanel'>
<h1>First</h1>
<ul>
<li>HappyPath</li>
</ul>
<h1>Second</h1>
//
// Define this.constructor.name so we can introspect an object for it's constructor's name
// (equivalent to the 'Class' name if there were classes...)
// This is necessary because IE does not define this constructor property but FF does.
//
Function.prototype.getName = function() {
var matches = this.toString().match(/function\s+([\w\$]+)\s*\(/);
return matches ? matches[1] : '';
};