Skip to content

Instantly share code, notes, and snippets.

public class MainWindow {
public static void main(String[] args) {
// Write code that creates a window with a button
}
}
@codeguru42
codeguru42 / MainWindow.java
Last active December 11, 2015 02:59
Color Selector test
public class MainWindow {
public static void main(String args[]) {
SwingUtilities.invokeLater(new Runnable()) {
JFrame f = new JFrame("Color Selector Test");
f.add(new MainPanel());
f.pack();
f.setVisible(true);
}
}
}
@codeguru42
codeguru42 / gist:5545537
Created May 9, 2013 04:19
OnTouchListeners
albumCover.setOnTouchListener(new OnTouchListener() {
public void onTouch(View v, MotionEvent event) {
// What happens when an albumCover is touched
}
});
channelName.setOnTouchListener(new OnTouchListener() {
public void onTouch(View v, MotionEvent event) {
// What happens when an channelName is touched
}
@codeguru42
codeguru42 / gist:7505644
Created November 16, 2013 21:34
I can't count
successes = 0
failures = 0
for sfMilestone in data["milestones"]:
ghMilestone = milestone.sf2github(sfMilestone)
response = requests.post(
'https://api.github.com/repos/' + username + '/' + repo + '/milestones',
data=json.dumps(ghMilestone),
auth=(username, password))
@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))
@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 / 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 / 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 / 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 / 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