Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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

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 / annotate_gource_log.py
Last active December 17, 2015 22:08
Insert the filename into a custom gource log
# Based on https://code.google.com/p/gource/issues/detail?id=8#c27
#
# Usage:
# for x in *; do
# gource --output-custom-log $x.txt /path/to/repos/$x
# done
# python annotate_gource_log.py *.txt | sort -n > combined.txt
# gource combined.txt
import fileinput, sys
@orip
orip / vulcan_nginx
Last active December 18, 2015 16:09
UPDATE: a much-improved version is now in the nginx-buildpack repository. Building nginx with rewrite_module for use in heroku buildpacks.
#!/bin/bash
# An improved version is now in the nginx-buildpack repository:
# https://github.com/ryandotsmith/nginx-buildpack/blob/17b290ed880a182ef27f438eab3070f081c0ee0e/scripts/build_nginx.sh
#
# Building nginx with rewrite_module for use in heroku buildpacks - specifically in @ryandotsmith's https://github.com/ryandotsmith/nginx-buildpack.
# Uses heroku's vulcan for building (`gem install vulcan`).
# Can be used as a template for any kind of compile-time configuration of nginx.
cd $(mktemp -d /tmp/vulcan_nginx.XXXXXXXXXX)
echo $PWD
@orip
orip / android_lint_summarizer.py
Created June 27, 2013 09:15
Summarize the warning categories printed by Android Lint. Usage: lint <src_dir> | android_lint_summarizer.py Reference: http://developer.android.com/tools/help/lint.html
#!/usr/bin/env python
#
# Sample usage:
#
# % lint my_android_app | android_lint_summarizer.py
# 26 SpUsage
# 10 I18N HardcodedText
# 8 Accessibility ContentDescription
# 2 Typos
# 1 IconDuplicates
@orip
orip / PicassoUtils.java
Last active July 18, 2018 08:39
Working around https://github.com/square/okhttp/issues/184 for Picasso 2.x (older revisions for Picasso 1.1.1)
package com.example;
import android.content.Context;
import com.squareup.okhttp.HttpResponseCache;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.OkHttpDownloader;
import com.squareup.picasso.Picasso;
import javax.net.ssl.SSLContext;
import java.io.File;
@orip
orip / build.gradle
Created August 7, 2013 13:00
dagger in gradle
dependencies {
def dagger_version = "1.1.0"
compile "com.squareup.dagger:dagger:${dagger_version}"
compile "com.squareup.dagger:dagger-compiler:${dagger_version}"
}
@orip
orip / JdkBasedTimeZoneProvider.java
Last active January 14, 2017 03:20
A Joda time zone provider based on the JVM's TimeZone implementation, instead of Joda's Olson database. This can reduce Joda's initialization time (during class loading) by several seconds on Android. Inspired by http://stackoverflow.com/a/6298241/37020, but implemented from scratch. Requires Guava, for ImmutableSet.
/*
* Copyright (C) 2013 Onavo Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software