Skip to content

Instantly share code, notes, and snippets.

View rcky's full-sized avatar

Michael Rüfenacht rcky

  • Zvoove
  • Basel
View GitHub Profile
@rcky
rcky / schema.json
Last active December 15, 2022 16:09
Schema Test
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "gav-service-dump-file-shrink",
"type": "object",
"properties": {
"structure": {
"type": "array",
"description": "the structure of the criteria tree",
"items": {
"title": "CriteriaTreeNode",
@rcky
rcky / parameter-passing.js
Created June 4, 2015 13:10
How to pass the paging to the request parameters.
var rule =
{
name: 'parameter'
, path: /.*p-(\d+).*/ // the regex to execute against the pathname
, field: 'paging'
, value: function(match){
return match[0];
}
};
@rcky
rcky / test.nunjucks.html
Last active August 29, 2015 14:07
Nunjucks Render Error
var log = require('ee-log')
, nunjucks = require('nunjucks')
, path = require('path');
var env = new nunjucks.Environment(
new nunjucks.FileSystemLoader(path.join(__dirname, 'templates'))
);
try {
env.render('test.nunjucks.html', {}, function(err, res){
@rcky
rcky / fork-join
Last active August 29, 2015 14:05
var dispatcher = {
fork: function(join){
var context = {
expected: 0
, errors: []
, results: []
, addResult: function(error, result){
this.errors.push(error);
this.results.push(result);
}
@rcky
rcky / xss_alert
Last active August 29, 2015 14:02
XSS_alert
(function(){
// used for the xss game
alert('xss');
})();
@rcky
rcky / render_method_of_template
Last active August 29, 2015 14:01
Nunjucks throwing syntax error on asynchronous rendering
/**
* Consider line 17 which will throw an error instead of passing it to the callback.
*/
{
render: function(ctx, frame, cb) {
if (typeof ctx === 'function') {
cb = ctx;
ctx = {};
}
else if (typeof frame === 'function') {
@rcky
rcky / Custom-Header-Grammar
Last active December 29, 2015 15:28
PEG.js parser for custom headers (for Restful applications). https://github.com/joinbox/guidelines/blob/master/styleguide/RESTful.md
{
var argumentsList = function(first, more){
var sg = [first];
for(var i=0; i<more.length; i++){
sg.push(more[i][1]);
}
return sg;
};
}
@rcky
rcky / extended_handlebars
Last active December 27, 2015 14:09
Rough draft of an include/extends/block grammar in PEGjs.
{
var Water = function(value){
this.value = value;
this.visit = function(visitor){
return visitor.visitWater(this);
};
};
}
/**
@rcky
rcky / nested_set.php
Created October 22, 2013 15:26
Example code for basic tree management in a nested set environment.
<?php
class Node
{
protected $left;
protected $right;
protected $parent;
protected $children;
protected $id;
@rcky
rcky / gist:5442535
Last active December 16, 2015 13:38
Wordpress/i18n with composer
{
"require": {
"wordpress/i18n": "*"
},
"repositories": [
{
"type": "package",
"package": {
"name": "wordpress/i18n",
"type": "vcs",