Skip to content

Instantly share code, notes, and snippets.

package cnelson.server.entity;
import cnelson.server.connection.Connection;
/**
* User: Cory
* Date: 01/11/12
* Time: 20:33
*/
public class Entity extends Connection {
package cnelson.server.connection.stream;
/**
* User: Cory
* Date: 01/11/12
* Time: 17:58
*/
public class Stream {
private byte[] buffer;
public void run() {
while(!shutDown) {
try {
long lastTicks = System.currentTimeMillis();
selector.selectNow();
for (SelectionKey key : selector.selectedKeys()) {
if (key.isAcceptable()) {
SocketChannel socket = serverChannel.accept();
if (socket == null)
continue;
package com.net;
import java.nio.ByteBuffer;
/**
* User: Cory
* Date: 01/11/12
* Time: 01:15
*/
public class Packet {
WebClient webClient = new WebClient();
HtmlPage page1 = webClient.getPage("http://www.funkypool.com/logon.do");
HtmlForm form = page1.getFirstByXPath("//form[@action='/logon.do']");
HtmlSubmitInput button = form.getInputByValue("ok");
HtmlTextInput username = form.getInputByName("username");
HtmlPasswordInput userpassword = form.getInputByName("userpassword");
username.setText("...");
userpassword.setText("...");
if(input.isKeyPressed(37) || input.isKeyPressed(39) || input.isKeyPressed(38) || input.isKeyPressed(40)) { // Movement
boolean left = input.isKeyPressed(37);
boolean right = input.isKeyPressed(39);
boolean up = input.isKeyPressed(38);
boolean down = input.isKeyPressed(40);
if(block.x1 == block.x2 && block.y1 == block.y2) {
if(left || right) {
block.x1 += (left ? -2 : 1);
block.x2 += (left ? -1 : 2);
}
if(input.isKeyPressed(37) || input.isKeyPressed(39) || input.isKeyPressed(38) || input.isKeyPressed(40)) { // Movement
boolean left = input.isKeyPressed(37);
boolean right = input.isKeyPressed(39);
boolean up = input.isKeyPressed(38);
boolean down = input.isKeyPressed(40);
if(block.x1 == block.x2 && block.y1 == block.y2) {
if(left || right) {
block.x1 += (left ? -2 : 1);
block.x2 += (left ? -1 : 2);
}
package blox.input;
import java.awt.*;
import java.awt.event.*;
/**
* User: Cory
* Date: 20/10/12
* Time: 22:36
*/
@CoryNelson
CoryNelson / main
Created October 18, 2012 14:29
Week 4, Question 1
#include <iostream>
using namespace std;
int main()
{
float a, b;
//Gets the first value from the user.
cout << "Enter the first value:";
@CoryNelson
CoryNelson / main
Created October 18, 2012 14:28
Week 4, Question 2
#include <iostream>
using namespace std;
const float SMALL_RATE = 0.02;
const float LARGE_RATE = 0.05;
int main()
{
float balance, interest;