Skip to content

Instantly share code, notes, and snippets.

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

@orip
orip / ViewGroupUtils.java
Created May 13, 2013 07:20
Find all Android views tagged with a given value. Similar to document.getElementsByClassName in JavaScript/DOM to find elements with a given class. Based on this StackOverflow answer by Shlomi Schwartz: http://stackoverflow.com/a/8831593/37020
package com.onavo.android.common.ui;
import android.view.View;
import android.view.ViewGroup;
import java.util.LinkedList;
import java.util.List;
/**
* Based on http://stackoverflow.com/a/8831593/37020 by by Shlomi Schwartz
@orip
orip / build.gradle
Created February 14, 2013 09:52
Print Gradle test results to console
/*
Sample output:
> gradle test ruby-1.9.3-p194 testing_with_gradle 9179829 ✗
...
:test
Results: SUCCESS (84 tests, 74 successes, 0 failures, 10 skipped)
*/
test {
testLogging {
@orip
orip / mysqldump2sqlite3.sh
Created September 23, 2012 15:23 — forked from orenhe/mysqldump2sqlite3.sh
Convert a mysql database dump into something sqlite3 understands.
#!/bin/sh
# ================================================================
#
# Convert a mysql database dump into something sqlite3 understands.
#
# Adapted from
# http://stackoverflow.com/questions/489277/script-to-convert-mysql-dump-sql-file-into-format-that-can-be-imported-into-sqlit
#
# (c) 2010 Martin Czygan <martin.czygan@gmail.com>
@orip
orip / GsonHelper.java
Created September 5, 2012 11:22
Gson type adapter to serialize and deserialize byte arrays in base64
import java.lang.reflect.Type;
import android.util.Base64;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
@orip
orip / weakself_macro.h
Created August 23, 2012 11:02
WEAKSELF macro for Objective-C and ARC
/*
Usage:
WEAKSELF_T weakSelf = self;
dispatch_async(queue, ^{
[weakSelf coolStuff];
});
*/
#if __has_feature(objc_arc_weak)
#define WEAKSELF_T __weak __typeof__(self)
#!/bin/sh
# inspired by http://www.cimgf.com/2011/02/20/revisiting-git-tags-and-building/git_hash=`git rev-parse --short HEAD 2>/dev/null || echo "nohash"`
TARGET_FILE=${PROJECT_TEMP_DIR}/InfoPlist.h
echo "#define GIT_HASH $git_hash" > $TARGET_FILE
touch $INFOPLIST_FILE
@orip
orip / temp_chdir.py
Created July 22, 2012 19:22
temp_chdir
import os, contextlib
@contextlib.contextmanager
def temp_chdir(path):
"""
Usage:
>>> with temp_chdir(gitrepo_path):
... subprocess.call('git status')
"""
starting_directory = os.getcwd()
@orip
orip / bugsense_bugs_to_json.js
Created June 26, 2012 12:14
Dump JSON describing android bugs on BugSense
console.log(JSON.stringify($('#error-sum-table .e').map(function(i, x) {
var $x = $(x);
var message = $x.find('.error-name').text().trim();
var count = parseInt($x.find('.counter').text().trim());
var filegroups = $x.find('.class-file').text().trim().match(/File: ([^ ]*)/);
var appvers = $x.find('.app_version').map(function(i, x) {
return $(x).text().trim();
});
var bugid = $x.find('.middle').data('id');
return {
@orip
orip / .gitignore
Created May 1, 2012 18:03
fdkiller in Ruby
.*.swp