Skip to content

Instantly share code, notes, and snippets.

View avh4's full-sized avatar

Aaron VonderHaar avh4

View GitHub Profile
@avh4
avh4 / Main.java
Created August 7, 2008 07:27
Example of collision detection using java.awt.geom.Area with AffineTransform's
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package collisiondemo;
import java.util.logging.Level;
import java.util.logging.Logger;
@avh4
avh4 / gist:71342
Created February 27, 2009 07:56
Creating a window - Wintriss Tech
// Create the window
JFrame window = new JFrame("Window Title");
// Make the program exit when the window is closed
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Add the components to the window
window.add(new JButton());
window.pack();
@avh4
avh4 / gist:71348
Created February 27, 2009 08:04
Finding the width of rendered text - Wintriss Tech
// Create the font and pass it to the Graphics context
g2.setFont(new Font("Monospaced", Font.BOLD, 24));
// Get measures needed to center the message
FontMetrics fm = g2.getFontMetrics();
// How many pixels wide is the string
int msg_width = fm.stringWidth(msg);
// Create the variable for the image's URL
URL spaceshipImageURL;
// Get the URL of the image
spaceshipImageURL = getClass().getResource("my_spaceship.png");
// Create the variable for the image
Image spaceshipImage;
// Load the image from the URL
spaceshipImage = ImageIO.read(spaceshipImageURL);
@avh4
avh4 / gist:87303
Created March 29, 2009 06:52
the describe_project method doesn't work as I'm expecting it to. The following will not run the before block for each of the tests.
require File.dirname(__FILE__) + '/../spec_helper.rb'
def describe_project(name, &block)
describe name do
before(:each) do
@project = File.dirname(__FILE__) + "/../../test_data/#{name}/#{name}.xcodeproj"
@reader = XcodeprojReader::Reader.new(@project)
end
yield
end
Scenario Outline: Religious menus
Given the customer is "<Religion>"
When he asks for the menu
Then he should see pork selections if <Pork>
And he should see lamb selections if <Lamb>
And he should see veal selections if <Veal>
Scenarios:
| Religion | Pork | Lamb | Veal |
| Christian | Y | Y | Y |
JOptionPane.showInputDialog("Hello <Name>");
package iphonedemo;
import org.xmlvm.iphone.CGRect;
import org.xmlvm.iphone.UIApplication;
import org.xmlvm.iphone.UILabel;
import org.xmlvm.iphone.UIScreen;
import org.xmlvm.iphone.UITextAlignment;
import org.xmlvm.iphone.UIView;
import org.xmlvm.iphone.UIWindow;
AudioClip mySound = JApplet.newAudioClip(getClass().getResource("MySound.aiff"));
mySound.play();
@avh4
avh4 / MyActivityUnitTest.java
Created December 9, 2011 09:36
how to make an ActivityUnitTestCase that depends on a ContentProvider use test databases
@Override
protected void setUp() throws Exception {
super.setUp();
// Create a Context for our content provider that will use the test.*
// database instead of the production database
final String filenamePrefix = "test.";
final RenamingDelegatingContext testDatabaseContext = new RenamingDelegatingContext(
getInstrumentation().getTargetContext(), getInstrumentation()
.getTargetContext(), filenamePrefix);