Skip to content

Instantly share code, notes, and snippets.

View ehgoodenough's full-sized avatar

Andrew Goodenough ehgoodenough

View GitHub Profile
@ehgoodenough
ehgoodenough / GameFrame.css
Last active December 6, 2015 03:51
I wrote this mixin to fix an element to an absolute aspect ratio. It resizes the element relative to the viewport, or ``vw`` and ``vh``.
#frame {
top: 0rem;
left: 0rem;
right: 0rem;
bottom: 0rem;
margin: auto;
position: fixed;
overflow: hidden;
}
import java.net.URLConnection;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class HTTPtest
{
var makeRoboBakers = function(amount)
{
var robobake = function()
{
$("#bigCookie").click();
}
.bind(this)
for(var i = 0; i < amount; i++)
{
var fs = require("fs");
var jsdom = require("jsdom");
fs.readFile("home.html", function(errors, data) {
if(errors) {console.log(errors);}
data = data.toString();
jsdom.env(data, function (errors, window) {
if(errors) {console.log(errors);}
var $ = require("jquery")(window);
$(":empty").text("{% %f %}");
var mailer = require("nodemailer");
var scheduler = require("node-schedule");
scheduler.scheduleJob({hour: 0, minute: 0}, function() //runs this function every morning at midnight.
{
var transport = mailer.createTransport("SMTP", {service: "gmail", auth: require("./gmail.auth.js")});
var settings = {
from: "[email protected]",
to: "[email protected]",
@ehgoodenough
ehgoodenough / insortion.java
Last active December 21, 2015 21:09
An implementation of an iterative insertion sort.
public class Insortion
{
public static void main(String[] args)
{
char[] array = {'a', 'c', 'b', 'e', 'd'};
insertionSort(array);
for(int i = 0; i < array.length; i++) {System.out.print(array[i]);}
}
@ehgoodenough
ehgoodenough / kbdin.js
Last active December 17, 2015 13:49
As discussed over at www.stackoverflow.com/questions/14893988, binding the functionality of a keystroke to an action instead of a state will establish noninterrupting events while still preserving individual keystrokes.
var kbdin =
{
downbinded: new Object(),
upbinded: new Object(),
stroked: new Object(),
downbindKeystroke: function(keyCode, functionality)
{
this.downbinded[keyCode] = functionality;
},
@ehgoodenough
ehgoodenough / magicsquare.cpp
Last active December 17, 2015 10:58
A magic square is an array of numbers where the sum of each column or row return the same value. This class can analyze the array for a magic square.
class Square
{
private:
const int size;
int* grid;
public:
Square() : size(4) {grid = new int[size * size];}
Square(int size) : size(size) {grid = new int[size * size];}
void setNode(int value, int x, int y) {grid[y * size + x] = value;}
@ehgoodenough
ehgoodenough / columns.htm
Created May 8, 2013 00:22
By styling the columns as table, you can ensure that all elements of the page remain the same height, regardless of the amount of content.
<!DOCTYPE hmtl>
<html>
<head>
<style>
body
{
margin:0px;
}
#partition
@ehgoodenough
ehgoodenough / mergesort.java
Last active December 17, 2015 01:19
Although I managed to implement the recursive divide and conquer algorithm, the code generates a new array as it traverses up the stack, which is really quite wasteful. There must be a more efficient implementation that mergesorts the array all in place.
public class MergeSort
{
public static void main(String[] args)
{
int[] array = {57, 36, 13, 5, 24, 42, 68, 79};
array = sort(array);
for(int num = 0; num < array.length; num++)
{