Skip to content

Instantly share code, notes, and snippets.

View marcelklehr's full-sized avatar

Marcel Klehr marcelklehr

View GitHub Profile
@marcelklehr
marcelklehr / gist:1293564
Created October 17, 2011 19:42
CheatAss! A cheat for playing 'KickAss - Destroy the Web'. Simply make a bookmark out of it!
javascript:ASTEROIDS.watch('enemiesKilled', function(prop, old, newval) {return newval+4;});void(0);
@marcelklehr
marcelklehr / contrast.js
Created December 30, 2011 16:14
Calculate contrast from two RGB colors.
function contrast(c1, c2) {
v1 = Math.min(Math.min(c1.r, c1.g),c1.b) + Math.max(Math.max(c1.r, c1.g),c1.b) / 2;
v2 = Math.min(Math.min(c2.r, c2.g),c2.b) + Math.max(Math.max(c2.r, c2.g),c2.b) / 2;
return Math.abs(v1-v2);
};
@marcelklehr
marcelklehr / emulate.js
Created July 2, 2012 15:28
Emulating a terminal command with node
var exec = require('child_process').spawn;
var node = exec('node', process.argv.splice(2), {stdio: 'inherit'});
@marcelklehr
marcelklehr / preview.md
Created August 6, 2012 18:07
Dev workflow description with helpful links.
[Fork](http://help.github.com/fork-a-repo/) this repo, [clone](http://git-scm.com/docs/git-clone) your fork, create a [feature branch](https://www.google.com/search?q=git+feature+branches), [commit](http://git-scm.com/docs/git-commit), [push](http://git-scm.com/docs/git-push) and submit a [pull request](http://help.github.com/send-pull-requests/).
                                     [diff algorithm]
server ↔ Socket.io  → *changeset* →  Client controller  → *new contents* →  Editor
                 \                   /              \                           /
                  `←  *changeset*  ←´                `←  *onchange:contents*  ←´

or just

@marcelklehr
marcelklehr / gist:3675941
Last active October 10, 2015 10:27
http app
  Routes
+------------------------------------------------+
|  Request                                       |        +---------------+
|    ||                                          | -----> |   Settings    |
|    \/       Auth                               |        +---------------+
| +--------------------------------------------+ |
| |   ||                                       | |
| |   \/                                       | |
| | +------------+    Model   +------------+   | |
src/node/handler/APIHandler.js:101: res.send({code: 3, message: "no such api version", data: null});
src/node/handler/APIHandler.js:119: res.send({code: 3, message: "no such function", data: null});
src/node/handler/APIHandler.js:126: res.send({code: 4, message: "no or wrong API Key", data: null});
src/node/handler/APIHandler.js:172: res.send({code: 0, message: "ok", data: data});
src/node/handler/APIHandler.js:177: res.send({code: 1, message: err.message, data: null});
src/node/handler/APIHandler.js:182: res.send({code: 2, message: "internal error", data: null});
src/node/handler/ExportHandler.js:59: res.send(text.text ? text.text : null);
src/node/handler/ExportHandler.js:64: res.send(pad.text());
src/node/handler/ExportHandler.js:79: res.send(dokuwiki);
src/node/handler/ExportHandler.js:111: res.send(html);
@marcelklehr
marcelklehr / gist:3885976
Created October 13, 2012 20:11
Test node's http.request
var http = require('http')
Number.prototype.times = function(fn) {
for(var i=1; i <= this; i++) process.nextTick(fn.bind(null, i))
return this
}
var finished=0;
function finish(i) {
finished++;
# v1.2 release
To complete these great news, we also released v1.1.6 today, introducing new patches and some exciting new features:
* Customizable robots.txt
* Customizable app title (finally you can name your epl instance!)
* eejs render arguments are now passed on to eejs hooks through the newly introduced `renderContext` argument.
* Plugin-specific settings in settings.json (finally allowing for things like a google analytics plugin)
* Serve admin dashboard at /admin (still very limited, though)
* Modify your settings.json through the newly created UI at /admin/settings
* Fix: Import <ol>'s as <ol>'s and not as <ul>'s!
* Added solaris compatibility (bin/installDeps.sh was broken on solaris)
@marcelklehr
marcelklehr / gist:6949300
Created October 12, 2013 12:04
Etherpad changelog v.1.2.12
* NEW: Add explanations for more disconnect scenarios
* NEW: export sessioninfos so plugins can access it
* NEW: pass pad in postAceInit hook
* NEW: Add trustProxy setting. ALlows to make ep use X-forwarded-for as remoteAddress
* NEW: userLeave hook (UNDOCUMENTED)
* NEW: Plural macro for translations
* NEW: backlinks to main page in Admin pages
* NEW: New translations from translatewiki.net
* SECURITY FIX: Filter author data sent to clients
* FIX: Never keep processing a changeset if it's corrupted