Skip to content

Instantly share code, notes, and snippets.

View wtfaremyinitials's full-sized avatar

Will Franzen wtfaremyinitials

View GitHub Profile
@wtfaremyinitials
wtfaremyinitials / maze.js
Created June 5, 2014 00:35
Maze solver in NodeJS for /r/dailyprogrammer challenge
// My solution to this /r/dailyprogrammer challenge on reddit (http://redd.it/278ptv)
process.stdin.resume();
process.stdin.setEncoding('utf8');
var width = 0;
var height = 0;
var maze = [];
function getStartPoint() {
for(var x = 0; x < maze.length; x++) {
@wtfaremyinitials
wtfaremyinitials / KarelPlusPlus.java
Last active August 29, 2015 14:04
KarelPlusPlus.java
package xyz.will.karelplusplus;
import stanford.karel.SuperKarel;
public class KarelPlusPlus extends SuperKarel {
private static final long serialVersionUID = 1L;
// Turn Right
public void turnRight() {
@wtfaremyinitials
wtfaremyinitials / timeago.js
Created September 25, 2014 19:00
Meteor timeAgo
/*
* Meteor timeAgo helper
* by
* MIT License
*/
UI.registerHelper('formatTimeAgo', function(timestamp, options) {
var minute = 60;
var hour = minute * 60;
var day = hour * 24;
var week = day * 7;
@wtfaremyinitials
wtfaremyinitials / KarelIconSwitcher.java
Last active August 29, 2015 14:07
KarelIconSwitcher.java
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.ImageIO;
@wtfaremyinitials
wtfaremyinitials / regex
Last active August 29, 2015 14:09
iPhone Model Regex
/^(4s?|5(c|s)?|6\+?)$/i
@wtfaremyinitials
wtfaremyinitials / test.js
Created April 2, 2015 20:53
Generator function tasks
var MiningTask = function* MiningTask() {
for(var i=0; i<5; i++) {
yield breakBlock();
}
}
var tasks = [];
tasks.push(MiningTask());
@wtfaremyinitials
wtfaremyinitials / example.js
Last active August 29, 2015 14:18
Example of my "Duties" API
var Duties = require('./index.js');
var main = new Duties();
var bot = new Bot(); // stub for other bot related code
var MiningTask = function* MiningTask(d, config) {
while(true) {
var block = bot.findBlockToBreak();
d.add(NavigateTask, block.location);
d.add(BreakBlockTask, block);
@wtfaremyinitials
wtfaremyinitials / wbot.js
Created April 5, 2015 02:16
Duties examlpe
var mineflayer = require('mineflayer');
var navigatePlugin = require('mineflayer-navigate')(mineflayer);
var blockfinderPlugin = require('mineflayer-blockfinder')(mineflayer);
var scaffoldPlugin = require('mineflayer-scaffold')(mineflayer);
var Duties = require('duties');
var BaseTask = function* BaseTask($) {
while(true) {
setTimeout($.resume, 500);
@wtfaremyinitials
wtfaremyinitials / copy.js
Created April 23, 2015 19:00
Javascript copy to clipboard
function copytext(text) {
var textField = document.createElement('textarea');
textField.innerText = text;
document.body.appendChild(textField);
textField.select();
document.execCommand('copy');
textField.remove();
}
// credit to reddit.com/u/liamht
@wtfaremyinitials
wtfaremyinitials / notify.js
Created April 23, 2015 19:04
Desktop notifications in Javascript
function notify(message, iconUrl, onclick) {
if (!Notification) {
alert(message);
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
var notification = new Notification('', {