Skip to content

Instantly share code, notes, and snippets.

View BonsaiDen's full-sized avatar

Ivo Worms BonsaiDen

View GitHub Profile
// A simple Demo for creating a Java 2D Game Engine
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Transparency;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
// Bits and pieces *cough* stolen *cough* from
// Micheil Smith's node-websocket-server
// <http://github.com/miksago/node-websocket-server>
// Therefore, I don't really think that I should claim any copyright for
// this piece of "minified" code.
var http = require('http');
var crypto = require('crypto');
@BonsaiDen
BonsaiDen / round.js
Created October 25, 2010 12:08
Math.round faster, like 40% or something
function round(data) {
if (data < 0) {
var l = (data + 1 | 0) - data;
return (l >= 1.0 && l <= 1.5) ? data | 0 : data - 1 | 0;
}
var l = data | 0;
return data - l >= 0.5 ? data + 1 | 0 : l;
}
@BonsaiDen
BonsaiDen / bezierCurve.js
Created November 10, 2010 02:24
Bezier Curve in JS, includes arc-length parameterization stuff
function Bezier(a, b, c, d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.len = 100;
this.arcLengths = new Array(this.len + 1);
this.arcLengths[0] = 0;
@BonsaiDen
BonsaiDen / Generic 2D Map Engine
Created November 18, 2010 15:25
A design template for a generic Map Engine
Map(width, height)
<MapLayer> layers
<int[]> layerOffsets
int width
int height
.addLayer(mapLayer, layerID)
.removeLayer(layerID)
.raiseLayer(layerID)

[Node.js][1] is an event based, asynchronous I/O framework that runs on top of Google's [V8 JavaScript engine][2].

Node.js - or just Node as it's commonly called - is used for developing applications that make heavy use of the ability to run [JavaScript][3] both on the client, as well as on server side and therefore benefit from the re-usability of code and the lack of context switching.

It's also possible to use majored JavaScript frameworks like [YUI][4] and [jQuery][5] for server side DOM manipulation.

To ease the development of complex JavaScript further, Node.js supports the [CommonJS][6] standard that allows for modularized development and the distribution of software in packages via the [Node Package Manager][7].

Applications that can be written using Node.js include (but are not limited to):

@BonsaiDen
BonsaiDen / KittenFoo
Created December 9, 2010 09:14
foo.js
foo
@BonsaiDen
BonsaiDen / vimrc.vim
Created January 4, 2011 17:30
My .vimrc
" Basics
set t_Co=256
colorscheme symfony
set guifont=Monospace\ 8
set number
let g:superTabDefaultCompletionType = "context"
" Filetype stuff
filetype on
@BonsaiDen
BonsaiDen / vim256toGUI.py
Created May 10, 2011 19:29
Small python script converting a 256 colorscheme to a GUI one
import sys
# Color list taken from https://gist.github.com/719710
COLORS = [ # color look-up table
# Primary 3-bit (8 colors). Unique representation!
('00', '000000'),
('01', '800000'),
('02', '008000'),
@BonsaiDen
BonsaiDen / ???.js
Created July 12, 2011 20:45
952 bytes
function lf(a){for(var b,c,d,e,f=[],g=[],h={},i=/([^\\]|^)(\{([^\{\}]+[^\\\}]|[^\{\\\}]|)\})/g,j,k,l=0,m=function(a,b){a=g[a<0?l+a:a];if(d=a[2])for(e=0;e<d.length;e++)b=b&&b[d[e]];f[a[0]]=b;return n},n={at:m,map:function(a){c=a.length;if(+c===c)for(b=0;b<c;)m(b,a[b++]);else for(b in a)n[b]&&n[b](a[b]);return n},each:function(a){for(b=0;b<l;)d=g[b++],f[d[0]]=a(b,d[1],d[2]);return n},toString:function(){return f.join("")}};;){f.push.call(f,a.substring(i.lastIndex,(j=i.exec(a))?j.index+!!j[1]:a=k).replace(/\\(\{|\})/g,"$1"),j?j[2]:k);if(!j)return n;if(/\.|\[/.test(e=j=j[3]))for(j=(c=/\.?([^\.\[]+)|\[(\d+|('|")(|.*?[^\\])\3)\]/g).exec(e)[1],b=[];d=c.exec(e);b.push(d[4]!=k?d[4]:d[2]!=k?+d[2]:d[1]));n[j]||(n[j]=function(a){return function(c){for(b=0;b<a.length;)m(a[b++],c);return n}}(h[j]=[]),n[j+"s"]=function(a){return function(f){for(b=0,d=a.length,c=f.length,e=c<d?c:d;b<e;)m(a[b],f[b++]);return n}}(h[j])),g.push([l*2+1,j,b]),h[j].push(l++)}}