Skip to content

Instantly share code, notes, and snippets.

View cnevinc's full-sized avatar

Nevin cnevinc

View GitHub Profile
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
/** Got flaky tests? Shampoo them away. */
public final class ShampooRule implements TestRule {
private final int iterations;
public ShampooRule(int iterations) {
if (iterations < 1) throw new IllegalArgumentException("iterations < 1: " + iterations);
package com.example.scalpeldrawer;
import android.app.Activity;
import android.content.Context;
import android.support.v4.widget.DrawerLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
/**
* Proxying implementation of Context that simply delegates all of its calls to
* another Context. Can be subclassed to modify behavior without changing
* the original Context.
*/
public class ContextWrapper extends Context {
Context mBase;
public ContextWrapper(Context base) {
mBase = base;
@cnevinc
cnevinc / Application.java
Created March 22, 2015 10:02
Application.java
public class Application extends ContextWrapper implements ComponentCallbacks2 {
public Application() {
super(null);
}
/**
* Called when the application is starting, before any activity, service,
* or receiver objects (excluding content providers) have been created.
* Implementations should be as quick as possible (for example using
* lazy initialization of state) since the time spent in this function
* directly impacts the performance of starting the first activity,
public class XXXXXApplication extends Application
{
public XXXXXApplication()
{
instance = this;
}
public void onCreate()
{
params = new Bundle();
SpInfo spinfo = new SpInfo(this);
package com.example.drawtest;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.RectF;
@cnevinc
cnevinc / merge_to_master
Created August 8, 2014 23:00
merge dev to master
git checkout master
git pull origin master
git merge develop
git push origin master
@cnevinc
cnevinc / addFooterHeaderView
Created May 8, 2014 17:36
set footer/header view of a listview
LinearLayout v = (LinearLayout) LayoutInflater.from(this)
.inflate(R.layout.listview_header, null);
swipeListView.addFooterView(v);
swipeListView.addHeaderView(v);
swipeListView.setAdapter(adapter);
Entity bookShelf = schema.addEntity("BookShelf");
bookShelf.addIdProperty();
Entity book = schema.addEntity("Book");
book.addIdProperty();
book.addStringProperty("name");
Property bookFKShelves = book.addLongProperty("bookShelf_id").notNull().getProperty();
book.addToOne(bookShelf, bookFKShelves);
bookShelf.addToMany(book, bookFKShelves);
<?php
$url = "http://www.google.com";
file_get_contents($url);
print_r( $http_response_header) ;
?>