Skip to content

Instantly share code, notes, and snippets.

View marcelklehr's full-sized avatar

Marcel Klehr marcelklehr

View GitHub Profile
@marcelklehr
marcelklehr / checkPadDeltas.js
Last active August 29, 2015 14:01
check etherpad deltas
/*
This is a debug tool. It checks all revisions for data corruption
*/
if(process.argv.length != 3)
{
console.error("Use: node bin/checkPad.js $PADID");
process.exit(1);
}
//get the padID
@marcelklehr
marcelklehr / index.js
Created June 16, 2015 21:21 — forked from Tuch/index.js
requirebin showing off vdom-virtualize's svf goodness
var dom = require('virtual-dom');
var fromHTML = require('vdom-virtualize').fromHTML;
var html = '<svg namespace = "http://www.w3.org/2000/svg" class="stats-aside__svg" height="160" width="160"> <circle namespace = "http://www.w3.org/2000/svg" class="stats-aside__svg-bg" cx="80" cy="80" r="78" stroke="#f2f2f2" stroke-width="4" fill="none" ></circle> <circle namespace = "http://www.w3.org/2000/svg" class="stats-aside__svg-progress" cx="80" cy="80" r="78" stroke="#f9c033" stroke-width="4" fill="none" stroke-dashoffset="228.92" stroke-dasharray="503, 999"></circle> </svg>'
var vsvg = fromHTML(html);
var node = dom.create(vsvg);
document.body.appendChild(node);
@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 / index.js
Last active November 5, 2015 19:09
requirebin example of a virtual-dom UI hook
var ObservStruct = require('observ-struct')
, ObservArray = require('observ-array')
, Computed = require('observ/computed')
, vdom = require('virtual-dom')
, h = vdom.h
var state = ObservStruct({
users: ObservArray([
ObservStruct({id: 0, name: 'foo'})
, ObservStruct({id:1, name: 'bar'})