Skip to content

Instantly share code, notes, and snippets.

View ecgreb's full-sized avatar

Chuck Greb ecgreb

View GitHub Profile
POST https://www.example.com/api/v1/login
{"username":"chuck@example.com", "passoword":"Kronos"}
{"user_id": 1234, "auth_token":"Y2h1Y2tAZXhhbXBsZS5jb20="}
GET https://www.example.com/api/v1/profile/1234567
{"name":"Chuck Greb", "avatar":"http://www.example.com/images/dh3d67kfb.jpg", "email":"chuck@example.com"}
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', %d],
['Onions', %d],
['Olives', %d],
['Pepperoni', %d]
]);
private void loadChart() {
int mushrooms = Integer.parseInt(mushroomsField.getText().toString());
int onions = Integer.parseInt(onionsField.getText().toString());
int olives = Integer.parseInt(olivesField.getText().toString());
int pepperoni = Integer.parseInt(pepperoniField.getText().toString());
String content = null;
try {
AssetManager assetManager = getAssets();
InputStream in = assetManager.open("hello-pizza-chart.html");
@ecgreb
ecgreb / CustomTestRunner.java
Last active July 11, 2016 14:01
CustomTestRunner (Robolectric 2.x) and Crashlytics shadow class
package com.example;
import com.example.shadows.ShadowCrashlytics;
import org.junit.runners.model.InitializationError;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.bytecode.ClassInfo;
import org.robolectric.bytecode.Setup;
import org.robolectric.bytecode.ShadowMap;
@ecgreb
ecgreb / ShadowCrashlytics.java
Created January 16, 2014 21:25
ShadowCrashlytics
package com.example.shadows;
import android.content.Context;
import com.crashlytics.android.Crashlytics;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
/**
04-30 16:09:46.174 22042-22049/com.mapzen E/dalvikvm﹕ Break split failed
04-30 16:09:46.174 22042-22049/com.mapzen E/dalvikvm﹕ VM aborting
04-30 16:09:46.174 22042-22049/com.mapzen A/libc﹕ Fatal signal 6 (SIGABRT) at 0x0000561a (code=-6), thread 22049 (Compiler)
04-30 16:09:46.234 172-172/? I/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-30 16:09:46.234 172-172/? I/DEBUG﹕ Build fingerprint: 'google/occam/mako:4.4.2/KOT49H/937116:user/release-keys'
04-30 16:09:46.234 172-172/? I/DEBUG﹕ Revision: '11'
04-30 16:09:46.234 172-172/? I/DEBUG﹕ pid: 22042, tid: 22049, name: Compiler >>> com.mapzen <<<
04-30 16:09:46.234 172-172/? I/DEBUG﹕ signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
04-30 16:09:46.354 172-172/? I/DEBUG﹕ r0 00000000 r1 00005621 r2 00000006 r3 00000000
04-30 16:09:46.354 172-172/? I/DEBUG﹕ r4 00000006 r5 00000000 r6 00005621 r7 0000010c
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:mapid="Your MapBox mapid" />
MapView mapView = new MapView(this, "examples.map-vyofok3q");
this.setContentView(mapView);
<org.oscim.android.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
private void onLocationClientConnected() {
Location lastLocation = locationClient.getLastLocation();
if (lastLocation != null) {
// do stuff
}
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setInterval(5000);
locationClient.requestLocationUpdates(locationRequest,
new LocationListener() {
@Override public void onLocationChanged(Location location) {