View .bash_profile
source ~/.git-completion.bash | |
export PS1='\u:\W\$ ' | |
export CLICOLOR=1 #ls with colors | |
# export EDITOR='vim -f' | |
# export EDITOR='subl -w' | |
export PATH=/usr/local/bin:$HOME/bin:$PATH | |
export PATH=$PATH:/setups/homebrew/bin |
View .gitconfig
[alias] | |
co = checkout | |
ci = commit | |
st = status | |
br = branch | |
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short | |
type = cat-file -t | |
dump = cat-file -p | |
[mergetool] |
View ios_app_link_redirector.html
<head> | |
<meta name="viewport" content="width=device-width"> | |
<meta http-equiv="cache-control" content="no-cache"> | |
<script type="text/javascript"> | |
function timeoutRedirect() { | |
var calledAt = Number(new Date()); | |
setTimeout( | |
function() { | |
if (Number(new Date()) - calledAt < 2000) { | |
window.location = "itms://itunes.apple.com/us/app/hangouts/id643496868"; |
View gist:5470389
- (void)reposition { | |
// https://developer.apple.com/library/ios/#qa/qa2010/qa1688.html | |
// tl;dr Only the first subview in the window receives orientation changes. | |
// So we apply a transform manually to rotate the view, and change the origin of the frame so | |
// that it remains in a top-center position for the user. | |
UIInterfaceOrientation orientation = | |
[UIApplication sharedApplication].statusBarOrientation; | |
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; | |
CGAffineTransform viewTransform = CGAffineTransformIdentity; |
View ruby_oauth_callback.rb
class OAuthController < ApplicationController | |
def authenticate | |
oauth_token = params[:oauth_token] | |
oauth_verifier = params[:oauth_verifier] | |
@user = User.find_by_oauth_token(oauth_token) | |
if !@user | |
# Do something appropriate, such as a 404 | |
else | |
begin |
View ruby_oauth_request_token.rb
oauth_request_url, oauth_token, oauth_token_secret = generate_request_token() | |
# save oauth_token and oauth_token_secret to @user | |
redirect_to oauth_request_url |
View NestedDict.py
class NestedDict(dict): | |
def __getitem__(self, key): | |
if key in self: return self.get(key) | |
return self.setdefault(key, NestedDict()) |
View ruby_oauth_token_generator.rb
require 'hmac-sha1' | |
require 'base64' | |
require 'cgi' | |
module OauthHelper | |
def URLEscape(text) | |
return CGI.escape(text).gsub("+", "%20") | |
end | |
View factors.rb
require "crack" | |
require "json" | |
files = File.read("files.txt").split("\n") | |
files.each { |filename| | |
filename = filename.strip | |
next if filename.empty? | |
myXML = Crack::XML.parse( File.read(filename) ) |
View Tunes.js
(function($) { | |
window.Album = Backbone.Model.extend({ | |
isFirstTrack: function(index) { | |
return index == 0; | |
}, | |
isLastTrack: function(index) { | |
return index >= this.get('tracks').length - 1; | |
}, |
NewerOlder