Skip to content

Instantly share code, notes, and snippets.

View joskuijpers's full-sized avatar

Jos Kuijpers joskuijpers

  • The Netherlands
View GitHub Profile
#include <node.h>
#include <v8.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <tchar.h>
//#include <iostream>
using namespace v8;
@joskuijpers
joskuijpers / gist:9712448
Last active August 29, 2015 13:57
Sphere OO API
=== SYSTEM ===
GetVersion System.version
GetVersionString System.versionString
Abort System.abort(msg)
Exit System.exit()
RestartGame System.restart()
System.sleep(double seconds)
Game.init = function() {
Screen.drawRect(10,10,Screen.width-20,Screen.height-20,Color.RED);
Screen.flip()
}
Game.loop = function() {
// something with statemanager or so
}
Game.states["load"] = function() {
@joskuijpers
joskuijpers / gist:9755025
Last active August 29, 2015 13:57
Pegasus scene node matrix transformations and rendering
=====
Lib
=====
function RenderNode() {
this.parent = null;
this.children = [];
this.vertices = [];
@joskuijpers
joskuijpers / gist:1f9d57870eed11eca506
Created July 30, 2014 12:43
Sample output from generic pool and pool, using poolLog.
Small explanation: first, watch this in a way you can see 1 line in full length, else it is unreadable.
* 'create client' is a message from pool.connect() in pool.js, after pool.acquire has been called. Here i set a variable to the client, called ___key,with a small text and the current date. This is to recognize the client.
* Then you see messages from the generic pool: they are from the ide remover, that is scheduled when a client is inside the pool (not used). At the end of the functon, if number of client in the pool > 0, it reschedules, otherwise, it does not reschedule.
* Then it figures the client has timed out (timeout here being the pool timeout, defined in the configuration. I put it very very fast in order to be able to test this reasonably. (reap 500ms, idle timeout 10s).
* 'ended' is in pool.destroy() (factory). It will then set _destroying to true and poolCount to undefined, and call client.end() (stream).
* generic pool tells us that all clients are removed (correctly so).
* Then the error come
function unwrapAsyncValue<T>(value: any, cb: (_err: any, _value: T) => void): void {
Promise.join(value, (unwrappedValue: any) => {
if (typeof unwrappedValue === "function") {
unwrappedValue(cb);
} else {
cb(null, unwrappedValue);
}
}).catch((err: Error) => cb(err, null));
}
function logClass(targetClass: any): () => void {
let originalClass = targetClass;
// Function to create new instances of a class.
function construct(constructor: Function, args: any[]): any {
let cls = function(): void {
return constructor.apply(this, args);
};
cls.prototype = constructor.prototype;
class Game {
constructor() {
assert(false && "Can't create another Game object");
}
get name() {
return "MyGame";
}
All resources are accessed using SPhereFS protocol
Default root is ~sgm/
If / is not prefixed, it is implied
/ equals to ~sgm/
I want:
./ or ../ to start from current file
return x()
.then(() => y())
.catch(() => {
return a()
.then(() => b());
});
EQUALS
return x()