Skip to content

Instantly share code, notes, and snippets.

View rpearce's full-sized avatar

Robert Pearce rpearce

View GitHub Profile
@rpearce
rpearce / keybase.md
Last active February 27, 2019 20:34

Keybase proof

I hereby claim:

  • I am rpearce on github.
  • I am rpearce (https://keybase.io/rpearce) on keybase.
  • I have a public key whose fingerprint is 6F5D 52E9 DEF3 D210 66AE 97F4 E8DD 20E4 8EFB 46B5

To claim this, I am signing this object:

@rpearce
rpearce / gist:6108224
Created July 29, 2013 21:55
Don't add transform: translateZ(0); to your body tag if you want fixed elements to work.
body {
transform: translateZ(0);
}
@rpearce
rpearce / .bash_profile
Last active July 26, 2016 08:39
Bash prompt & git prompt setup
# ~/.bash_profile
export PATH=/Users/rpearce/bin:$PATH
export PATH="/usr/local/sbin:$PATH"
eval "$(rbenv init -)"
eval "$(hub alias -s)"
alias brewup="brew update && brew upgrade && brew cleanup"
#!/bin/sh
###############################################################################
# XCode
###############################################################################
echo "Setting up XCode..."
xcodebuild -license
xcode-select --install
sudo xcode-select -switch /Library/Developer/CommandLineTools
@rpearce
rpearce / index.html
Created August 8, 2013 16:05
A CodePen by Robert Pearce.
<div class="wrapper">
<div class="box"></div>
<div class="box content">Some text</div>
</div>
@rpearce
rpearce / facebook_oauth_fix
Created July 31, 2013 15:56
jQuery fix for annoying #_=_ returned from Facebook Oauth
$(window).on('load', function(e) {
if (window.location.hash == '#_=_') {
window.location.hash = ''; // for older browsers, leaves a # behind
history.replaceState('', document.title, window.location.pathname); // nice and clean
e.preventDefault(); // no page reload
}
});
@rpearce
rpearce / redirect_to_seo_friendly_id.rb
Last active December 15, 2015 08:19
Redirect non-slugged id to SEO-friendly
// PostsController...
def show
@post = Post.find params[:id]
if params[:id] != @post.to_param
headers["Status"] = "301 Moved Permanently"
redirect_to post_url(@post)
end
end
@rpearce
rpearce / override_to_param_method.rb
Last active December 15, 2015 08:19
Override to_param method
// Post model
def to_param
sluggify("#{id}-#{location_from}-to-#{location_to}")
end
def sluggify str
slug = str.downcase.gsub(/[^0-9a-z_ -]/i, '')
slug = slug.gsub(/\s+/, '-').squeeze('-')
var user = new User();
var view = new UserShow({ model: user });
view.render();
$('body').append(view.el);​
var UserShow = Backbone.View.extend({
initialize: function() {
_.bindAll(this, 'render');
},
render: function() {
$('#name').html(this.model.get('fullName'))
this.fetchTrustCloudInfo();
},