Skip to content

Instantly share code, notes, and snippets.

@codeguru42
codeguru42 / gist:8551236
Last active January 4, 2016 01:49
Override an OnClickListener in a subclass
public class SubclassActivity extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View textView = findViewById(R.id.button1);
textView.setOnClickListener(new OnClickListener() {
@Override
package codeguru.exercise;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.google.zxing.client.android.CaptureActivity;
public class MainActivity extends Activity {
java.lang.NullPointerException
at bbct.android.common.activity.test.BaseballCardListWithDataTest.testSelectionAfterSaveInstanceState(BaseballCardListWithDataTest.java:462)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
@codeguru42
codeguru42 / gist:8226779
Created January 2, 2014 20:59
logging a test case
Log.d(TAG, "null activity");
this.setActivity(null);
Log.d(TAG, "change orientation");
this.activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Log.d(TAG, "restart activity");
this.activity = this.getActivity();
Log.d(TAG, "assertions");
lv = ((ListActivity) this.activity).getListView();
@codeguru42
codeguru42 / cards.csv
Last active January 1, 2016 22:49
Data for `testAddMultipleCards()`
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
1|Topps|1991|278|10000|1|Alex Fernandez|White Sox|Pitcher
2|Topps|1974|175|10000|1|Bob Stanley|Red Sox|Pitcher
3|Topps|1985|201|10000|1|Vince Coleman|Cardinals|Pitcher
4|TMG|1993|5|10000|1|Ken Griffey Jr.|All-Star|Pitcher
5|Upper Deck|1993|18|10000|1|Dave Hollins|Phillies|Pitcher
6|Upper Deck|1990|189|10000|1|Tom Browning|Reds|Pitcher
7|Topps|1982|121|10000|1|Ed Lynch|Mets|Pitcher
@codeguru42
codeguru42 / gist:8212496
Last active January 1, 2016 22:49
Error message for `testAddMultipleCards()`
java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:356)
at android.hardware.input.InputManager.injectInputEvent(InputManager.java:619)
at android.app.Instrumentation.sendKeySync(Instrumentation.java:886)
at android.app.Instrumentation.sendStringSync(Instrumentation.java:848)
at bbct.android.common.test.BBCTTestUtil.sendKeysToCurrFieldCardDetails(BBCTTestUtil.java:296)
at bbct.android.common.test.BBCTTestUtil.sendKeysToCardDetails(BBCTTestUtil.java:225)
at bbct.android.common.test.BBCTTestUtil.sendKeysToCardDetails(BBCTTestUtil.java:204)
@codeguru42
codeguru42 / list.hs
Created December 18, 2013 13:29
List parser
set = do
char '{'
result <- list
char '}'
return result
list = sepBy1 cell (char ',')
cell = many (noneOf ",}")
parseSet :: String -> Either ParseError [String]
@codeguru42
codeguru42 / Connect4.java
Last active December 31, 2015 09:39
Connect4 game
package codeguru.connect4;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
@codeguru42
codeguru42 / gist:7520720
Created November 18, 2013 01:02
'NoneType' object has no attribute '__getitem__'
sfTicket = [ticket for ticket in sfTickets if ticket['summary'] == issue['title']][0]
pprint(sfTicket['custom_fields']['_milestone'])
updateData = {'title' : issue['title']}
updateData['milestone'] = milestoneNumbers[sfTicket['custom_fields']['_milestone']]
@codeguru42
codeguru42 / gist:7508243
Created November 17, 2013 02:16
GitHub milestone query returns open milestones even when I request closed ones.
milestoneNumbers = {}
for state in ['open', 'closed']:
print("***" + state)
stateJSON = {'state' : state}
print(json.dumps(stateJSON))
response = requests.get(
'https://api.github.com/repos/' + username + '/' + repo + '/milestones',
data=json.dumps(stateJSON),
auth=(username, password))