Skip to content

Instantly share code, notes, and snippets.

Geoff Blair geoffb

Block or report user

Report or block geoffb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@geoffb
geoffb / simple_websocket_client.html
Created Oct 7, 2010
Super simple websockets client/server using Python. Compatible with the draft 76 challenge/response.
View simple_websocket_client.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>WebSocket Client</title>
<style>
#output {
border: solid 1px #000;
}
</style>
</head>
@geoffb
geoffb / simple-canvas-rotation.html
Last active Mar 28, 2019
A simple example of rotating a rectangle using HTML5 canvas.
View simple-canvas-rotation.html
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Canvas Transformation</title>
</head>
<body>
<script>
// Create our canvas and append it to the document body
var stage = document.createElement("canvas");
@geoffb
geoffb / edit-entities.js.diff
Created Jan 10, 2011
ImpactJS Weltmiester: Don't consider entity offset when snapping to grid.
View edit-entities.js.diff
diff --git a/htdocs/lib/weltmeister/edit-entities.js b/htdocs/lib/weltmeister/edit-entities.js
index f9d9250..6272f3e 100644
--- a/htdocs/lib/weltmeister/edit-entities.js
+++ b/htdocs/lib/weltmeister/edit-entities.js
@@ -141,7 +141,7 @@ wm.EditEntities = ig.Class.extend({
for( var i = 0; i < this.entities.length; i++ ) {
var ent = this.entities[i];
if( ent.touches(this.selector) ) {
- this.selector.offset = {x: (x - ent.pos.x + ent.offset.x), y: (y - ent.pos.y + ent.offset.y)};
+ this.selector.offset = {x: (x - ent.pos.x), y: (y - ent.pos.y)};
@geoffb
geoffb / command-repl.js
Created Dec 20, 2017
Simple example of a command REPL in Node.js
View command-repl.js
const readline = require("readline");
let input = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let queryCommand = () => {
input.question("Command: ", (command) => {
if (command === "exit") {
@geoffb
geoffb / permut.js
Created Feb 24, 2017
Calculate permutations
View permut.js
var permut = function (array, count, initial, output) {
if (initial.length >= count) {
output.push(initial);
} else {
for (var i = 0; i < array.length; ++i) {
permut(array, count, initial.concat(array[i]), output);
}
}
};
View canvas-path-fill-test.html
<!DOCTYPE html>
<html>
<head>
<title>Canvas Path Fill test</title>
</head>
<body>
<canvas id="stage" width="256" height="256"></canvas>
<script>
@geoffb
geoffb / QBasic.tmTheme
Created Sep 8, 2011
TextMate QBasic Theme - Just for fun
View QBasic.tmTheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>QBasic</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@geoffb
geoffb / animation.js.diff
Created Feb 16, 2011
Patch allowing Weltmeister to show the first frame of an entity's animation rather than the top left sprite in it's animation sheet.
View animation.js.diff
diff --git a/lib/impact/animation.js b/lib/impact/animation.js
index 20839f9..f367083 100644
--- a/lib/impact/animation.js
+++ b/lib/impact/animation.js
@@ -45,6 +45,7 @@ ig.Animation = ig.Class.extend({
this.frameTime = frameTime;
this.sequence = sequence;
this.stop = !!stop;
+ this.tile = this.sequence[0];
},
View jquery_events.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>jQuery Event Test</title>
<style>
.red {
background: #f00;
}
.blue {
background: #00f;
@geoffb
geoffb / astar.js
Created Jan 12, 2011
Simple A* Pathfinding
View astar.js
var AStar;
(function () {
var Node = function (index, x, y, parent) {
this.index = index;
this.x = x;
this.y = y;
this.parent = parent || null;
this.f = 0;
You can’t perform that action at this time.