Skip to content

Instantly share code, notes, and snippets.

@elevine
elevine / ListAdapter.java
Created May 3, 2011 23:34
Boilerplate code for creating an Android Adapter which is backed by an in memory List
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/**
* Adapter that is backed by an in memory List.
@elevine
elevine / createTable.java
Created August 8, 2011 15:15
Use within an Android SQLiteOpenHelper to generate database tables
/**
* Generates a ddl statement to create a table and executes it
*
* @param db
* @param tablename
* @param columnToType - a mapping of column names to their SQL types in the table
*/
private void createTable(SQLiteDatabase db, String tablename, Map<String,String> columnToType){
StringBuilder builder = new StringBuilder();
builder.append("CREATE TABLE " + tablename +" (");
@elevine
elevine / gist:1245475
Created September 27, 2011 16:00
Couchbase Android Test Application
import com.couchbase.android.CouchbaseMobile;
import com.couchbase.android.ICouchbaseDelegate;
import android.app.Activity;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
public class Main extends Activity {
package com.j256.ormlite.android;
import java.sql.SQLException;
import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.view.View;
import android.widget.ResourceCursorAdapter;
@elevine
elevine / gist:3239782
Created August 2, 2012 19:02
ActiveRecord establish_connection
#from module ConnectionHandling
def establish_connection(spec = ENV["DATABASE_URL"])
resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new spec, configurations
spec = resolver.spec
unless respond_to?(spec.adapter_method)
raise AdapterNotFound, "database configuration specifies nonexistent #{spec.config[:adapter]} adapter"
end
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
/*
* To change this template, choose Tools | Templates
@elevine
elevine / gist:4115762
Created November 20, 2012 03:29
ogr2ogr Python bindings example
import ogr2ogr
import string
import sys
def main():
#note: main is expecting sys.argv, where the first argument is the script name
#so, the argument indices in the array need to be offset by 1
ogr2ogr.main(["","-f", "KML", "out.kml", "data/san_andres_y_providencia_administrative.shp"])
@elevine
elevine / README.md
Last active July 11, 2019 08:51
Visualizing historical and predicted data with D3.

A graph which depicts historical and predicted data. Predicted data is represented by a dashed line, with a shaded area to indicate the error range.

gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
<html>
<head>
<title>Animated Sparkline using SVG Path and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke: steelblue;
stroke-width: 1;
fill: none;