Skip to content

Instantly share code, notes, and snippets.

View BonsaiDen's full-sized avatar

Ivo Worms BonsaiDen

View GitHub Profile
@BonsaiDen
BonsaiDen / leafy.js
Created July 17, 2011 21:31
Leafy - Small yet powerful templating (just 896 bytes with uglify)
/*
Leafy - Powerful yet small templating.
Copyright (c) 2011 Ivo Wetzel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@BonsaiDen
BonsaiDen / QY.js
Created July 25, 2011 20:54
A WIP concept of a multiplayer game server skeleton with lag compensation and stuff
/*
Copyright (c) 2011 Ivo Wetzel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@BonsaiDen
BonsaiDen / ws.js
Created July 27, 2011 06:37
Mini WebSocket Server supporting both the old 76/75 drafts as well as Version 8 of the protocol.
/*
Copyright (c) 2011 Ivo Wetzel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@BonsaiDen
BonsaiDen / Bench.js
Created August 27, 2011 00:43
Special Linked List
try {
var LinkedList = require('./Linked').LinkedList;
} catch(err) {
}
function timeTest(name, cb, count) {
var callbacks = cb(),
@BonsaiDen
BonsaiDen / Guard.js
Created September 2, 2011 22:24
Perverted JavaScript... checking for access violations based on member prefixing!
/**
* Copyright (c) 2011 Ivo Wetzel.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@BonsaiDen
BonsaiDen / guard.js
Created September 5, 2011 22:01
Guard.js | Access control in JavaScript by using ES5 features | Sorry Safari, you're out for not support function.caller.
/**
* Copyright (c) 2011 Ivo Wetzel.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@BonsaiDen
BonsaiDen / jump.c
Created November 17, 2011 22:23
Util code for a platformer
#include <stdio.h>
#define max(A, B) (A > B ? A : B)
// Calculate required initial force and downward acceleration for a jump of "height" in "time"
void jump_data(const float time, const int fps, const float height, float *force, float *acc) {
const float steps = time / (1.0f / fps);
*force = (height * (1.0f / steps)) * 2.0f;
*acc = *force / max(steps - 1.0f, 1.0f);
@BonsaiDen
BonsaiDen / get.py
Created November 28, 2011 21:58
Download thing
#!/usr/bin/env python3
import urllib.request as m
from time import *
p = print
def get(u, t=None, w=80):
p('[get] %s...' % u)
r, a, o, ls, w = time(), [0 for i in range(20)], 0, -1, w - 23
def _(b, bs, fs):
nonlocal o, ls
s, i = int((time() - r) * 10) % 20, b * bs
@BonsaiDen
BonsaiDen / javascript.vim
Created January 3, 2012 08:36
Customized JavaScript highlighting for VIM
" Vim syntax file
" Language: JavaScript
" Maintainer: Claudio Fleiner <claudio@fleiner.com>
" Updaters: Scott Shattuck (ss) <ss@technicalpursuit.com>
" URL: http://www.fleiner.com/vim/syntax/javascript.vim
" Changes: (ss) added keywords, reserved words, and other identifiers
" (ss) repaired several quoting and grouping glitches
" (ss) fixed regex parsing issue with multiple qualifiers [gi]
" (ss) additional factoring of keywords, globals, and members
" Last Change: 2010 Mar 25
@BonsaiDen
BonsaiDen / bitstream.js
Created January 12, 2012 15:46
BitStream
/*
* Copyright (c) 2011 Ivo Wetzel.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*