Skip to content

Instantly share code, notes, and snippets.

View avh4's full-sized avatar

Aaron VonderHaar avh4

View GitHub Profile
@avh4
avh4 / code for actionPerformed
Created February 6, 2012 03:30
Provided code for the Submarine project
iceX += iceSpeed;
if (iceX + iceWidth < 0)
{
iceX = windowWidth + r.nextInt(500);
iceSpeed = 2 + r.nextInt(25);
iceWidth = 30 + r.nextInt(30);
iceHeight = 60 + r.nextInt(20);
}
@avh4
avh4 / gist:1749471
Created February 6, 2012 04:03
Simple collision detection (both objects are rectangular)
if (aX < bX + bW
&& bX < aX + aW
&& aY < bY + bH
&& bY < aY + aH)
{
// A and B have collided!
}
@avh4
avh4 / gist:1781693
Created February 9, 2012 18:10
Creating a JFrame
JFrame window = new JFrame("My Game");
MyGame game = new MyGame();
window.add(game);
window.pack();
window.setLocation(100, 100);
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@avh4
avh4 / gist:1781768
Created February 9, 2012 18:18
Simple Graphics methods (Java Swing)
g.setColor(Color.GREEN);
g.drawRect(50, 50, 100, 100);
g.fillRect(50, 50, 100, 100);
g.drawOval(50, 50, 100, 100);
g.fillOval(50, 50, 100, 100);
g.drawLine(50, 50, 100, 100);
@avh4
avh4 / MyTestRunner.java
Created April 5, 2012 00:28
Robolectric Test Runner that sets up custom shadows
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.RobolectricTestRunner;
public class MyTestRunner extends RobolectricTestRunner {
public MyTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
addClassOrPackageToInstrument("com.package.ClassToShadow");
}
@avh4
avh4 / set_up_diffmerge.sh
Created April 27, 2012 16:58
Git mergetool configurations
# Download diffmerge from http://www.sourcegear.com/diffmerge/
git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd "diffmerge --merge --result=\$MERGED \$LOCAL \$BASE \$REMOTE"
git config --global mergetool.diffmerge.trustExitCode true
git config --global mergetool.keepBackup false
git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd "diffmerge \$LOCAL \$REMOTE"
@avh4
avh4 / list_weeks.sh
Created June 10, 2012 19:34
List the weeks between now and a given date
#!/bin/bash
# Lists the weeks between now and $1. You may specify the end date in any
# way that GNU date accepts, such as "Aug 25", "next year" or "2 months".
#
# If your system date is BSD date (like on Mac OS X), you will need to install
# GNU coreutils, ideally with http://mxcl.github.com/homebrew/
# "brew install coreutils"
@avh4
avh4 / imgur.sh
Created June 17, 2012 10:13
Script for uploading images to imgur.com
#!/bin/bash
# imgur script by Bart Nagel <[email protected]>
# version 2
# I release this as public domain. Do with it what you will.
#
# 2012-06-16 Aaron VonderHaar <[email protected]>
# - modified to work with BSD sed (don't use the -r flag)
# - disable the check for xsel / xclip
# - new API key
@avh4
avh4 / Rakefile
Created March 22, 2013 16:30
Build script for iOS projects
PROJECT_NAME = "AwesomeThing"
APP_NAME = "AwesomeThing"
@configuration = "Debug"
@app_suffix = "-Dev"
@staging_developer_name = "iPhone Developer: <<FILL ME IN>>"
@staging_provisioning_profile = "Support/AwesomeThing.mobileprovision"
@production_developer_name = "iPhone Distribution"
@production_provisioning_profile = "Support/AwesomeThing.mobileprovision"
@appstore_developer_name = "iPhone Distribution"
@appstore_provisioning_profile = "Support/AwesomeThing.mobileprovision"
@avh4
avh4 / CustomWidget.java
Created May 24, 2013 02:55
CustomWidget implementation in Java
public class CustomWidget extends JComponent {
private List<RenderingCommand> rendering;
public void draw(List<RenderingCommand> rendering) {
this.rendering = rendering;
repaint();
}
public void paintComponent(Graphics g) {
for (RenderingCommand command : rendering) {