Skip to content

Instantly share code, notes, and snippets.

View johnnypez's full-sized avatar
🏠
Working from home

John Butler johnnypez

🏠
Working from home
  • StitcherAds
  • Ireland
View GitHub Profile
Pingdom Traceroute from London
1 78.136.27.130 (78.136.27.130) 4.390 ms 4.558 ms 4.751 ms
2 core5a-aggr312a.lon3.rackspace.net (92.52.76.122) 0.491 ms 0.502 ms 0.548 ms
3 vl911.edge3.lon3.rackspace.net (92.52.76.196) 1.159 ms 1.220 ms 1.276 ms
4 ldn-b4-link.telia.net (213.248.85.201) 0.955 ms 0.981 ms 1.029 ms
5 cogent-ic-125507-ldn-b4.c.telia.net (213.248.70.238) 1.948 ms 2.037 ms 2.147 ms
6 te2-1.3493.mpd02.lon01.atlas.cogentco.com (130.117.2.18) 1.802 ms 1.622 ms te1-8.ccr01.lon01.atlas.cogentco.com (130.117.3.226) 32.614 ms
7 te3-3.ccr02.lon02.atlas.cogentco.com (130.117.48.154) 1.772 ms 1.880 ms 1.930 ms
8 te3-8.ccr02.ams03.atlas.cogentco.com (130.117.0.33) 9.154 ms 9.145 ms 9.141 ms
--- Sources/TTPhotoView.m (revision 175)
+++ Sources/TTPhotoView.m (working copy)
@@ -293,6 +293,7 @@
- (void)loadImage {
if (_photo) {
_photoVersion = TTPhotoVersionLarge;
+ self.defaultImage = self.image;
self.urlPath = [_photo URLForVersion:TTPhotoVersionLarge];
}
}
@johnnypez
johnnypez / 404.html
Created November 14, 2011 11:40
A nicer set of html5 error pages for Rails. Based on HTML5 Boilerplate
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Page Not Found :(</title>
<style>
body { text-align: center;}
h1 { font-size: 50px; text-align: center }
span[frown] { transform: rotate(90deg); display:inline-block; color: #bbb; }
body { font: 20px Constantia, 'Hoefler Text', "Adobe Caslon Pro", Baskerville, Georgia, Times, serif; color: #999; text-shadow: 2px 2px 2px rgba(200, 200, 200, 0.5); }
@johnnypez
johnnypez / rap.sh
Created March 7, 2012 13:28
put this in your .profile and be happy
function rap {
if [ "$1x" = "x" ]; then
echo "rap - shortcut to rake assets:precompile"
echo " usage rap [rails env]"
else
rake assets:clean assets:precompile RAILS_ENV=$1
fi
}
@johnnypez
johnnypez / asset_helper.js.erb
Created June 22, 2012 16:43
generate a js asset helper
<%
manifest = {}
app = Rails.application
env = app.assets
env.each_logical_path do |logical_path|
if File.basename(logical_path)[/[^\.]+/, 0] == 'index'
logical_path.sub!(/\/index\./, '.')
end
# grabbed from Sprockets::Environment#find_asset
@johnnypez
johnnypez / enum.rb
Created July 12, 2012 18:44
Enum for Ruby
# example
#
# States = enum %w(Draft Approved Published Trashed)
# => States {Draft, Approved, Published, Trashed}
#
# States::Draft
# => 1
#
# States::Approved
# => 2
@johnnypez
johnnypez / turbolinks_fb.js
Created September 28, 2012 12:39
getting turbolinks to play nice with FB SDK
@johnnypez
johnnypez / .profile
Created April 24, 2013 09:02
shows cwd / user / git branch info in bash prompt
function parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
function get_git_color() {
isred=`git status -s 2> /dev/null | egrep "^.[^? ]" | wc | awk '{print $1}'`
isorange=`git status -s 2> /dev/null | egrep "^[^? ]" | wc | awk '{print $1}'`
@johnnypez
johnnypez / jquery-rails-ajax-events.md
Last active December 17, 2015 08:49
jquery-rails ajax events

# rails:attachBindings

fired when jquery-rails starts attaching bindings to links, forms etc.

# confirm

gives you the opprotunity to skip a confirm dialog by returning a falsy value

# confirm:complete

@johnnypez
johnnypez / sync_locales
Created August 19, 2013 20:21
syncs keys from en.yml to other exisiting locale files
#!/usr/bin/env ruby
require 'yaml'
require 'active_support'
RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/../')
files = Dir.glob("#{RAILS_ROOT}/config/locales/*.yml")
locales = files.map{|f| File.basename(f, '.yml')}
def flat_hash(hash, k = nil)