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>
CXX=clang++
# suppress all warnings :-(
CXXFLAGS=-std=c++11 -stdlib=libc++ -Iapi -w
TARGET=pict
all:
$(CXX) $(CXXFLAGS) api/*cpp cli/*cpp -o $(TARGET)
test:
cd test; perl test.pl ../$(TARGET) rel.log
@orip
orip / rel.log.failures
Created November 19, 2015 08:10
PICT test failure w/clang++
EXP: 0 ACT: 2 bug020.txt /d:` /v
EXP: 0 ACT: 0.0078125 clus011.txt /o:5 /v
Seeding failure clus019.txt /v /r /e:.stdout
Seeding failure clus023.txt /d:space /v /r /e:.stdout
EXP: 0 ACT: 0.0078125 clus024.txt /d:space /v
EXP: 0 ACT: 0.0078125 clus024.txt /O:3 /d:space /v
Seeding failure clus100.txt /o:2 /v /r /e:.stdout
Seeding failure clus100.txt /o:3 /v /r /e:.stdout
Seeding failure clus101.txt /o:2 /v /r /e:.stdout
EXP: 0 ACT: 0.0078125 clus102.txt /o:1 /v

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 / 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 / AlarmHelper.java
Last active December 24, 2015 22:49
AlarmHelper that helps scheduling repeating non-wakeup inexact alarms. Define how to create the pending intent (e.g. getBroadcast vs getService), the alarm interval, and the first delay.
package com.example;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
import android.util.Log;
/**
@orip
orip / AnimationUtils.java
Last active December 25, 2015 02:09
Helper to simulate withEndAction in NineOldAndroids http://nineoldandroids.com/
package com.example;
import com.nineoldandroids.animation.Animator;
/*
* animate(view).alpha(0).setListener(AnimationUtils.withEndAction(new Runnable() {
* public void run() {
* view.setVisibility(View.GONE);
* view.setAlpha(1); // restore alpha
* }