Skip to content

Instantly share code, notes, and snippets.

View bbody's full-sized avatar
⌨️
Smashing out mad code

Brendon Body bbody

⌨️
Smashing out mad code
View GitHub Profile
@bbody
bbody / DirectionSpinner.java
Last active December 17, 2015 00:29
A bad example of a need for refactoring and UI decoupling
private void setupDirectionSpinner(){
busStop = inputTextEdit.getText().toString();
boundSpinner = (Spinner) this.findViewById(R.id.boundSpinner);
// Set up bound list
boundList = new ArrayList<String>();
boundList.add("Direction");
boundList.addAll(dbhelper.getDirections(busStop));
// Set up adapter
@bbody
bbody / testcases.java
Last active December 16, 2015 11:39
Set of test cases for integer division.
@Test
public void division(){
// Positive
Calculator c = new Calculator(4, 2);
assertEquals("Basic division", c.division(), 2);
c = new Calculator(8, 3);
assertEquals("Division with decimals", c.division(), 2);
c = new Calculator(50000000, 10000000);
@bbody
bbody / Calculator.java
Created April 21, 2013 06:44
Simple Integer Calculator class (Division deliberately wrong)
public class Calculator{
private int a, b;
public Calculator(int a, int b){
this.a = a;
this.b = b;
}
public int addition(){
return this.a + this.b;
}
private boolean postIssue(String description, String title, String username,
String password, String stub, String ownerUsername){
// Set up authentication
String authentication = username + ":" + password;
String encoding = Base64.encodeToString(authentication.getBytes(),
Base64.NO_WRAP);
URL url;
try {
// Setup URL with specified username (Owner) and repository stub
@bbody
bbody / testing.cs
Last active December 12, 2015 02:48
Quick automated GUI example.
[TestMethod]
public void MultiplicationNegativeBoth()
{
this.UIMap.StartApplication();
// Both negative decimal
this.UIMap.NegativePressed();
this.UIMap.FivePressed();
this.UIMap.MultiplicationPressed();
this.UIMap.NegativePressed();
@bbody
bbody / munger.php
Created November 2, 2012 11:41
Email Address Munger
<html>
<head>
<title>Email Address Munger</title>
</head>
<body>
<h3>Put your email in below</h3>
<form method='POST'>
<input type=text name='email'>
<input type=submit>
</form>