Skip to content

Instantly share code, notes, and snippets.

View silkentrance's full-sized avatar

Carsten Klein silkentrance

View GitHub Profile
@silkentrance
silkentrance / cfgsection
Last active April 28, 2016 18:14
Add/remove a marked section from a config file
#!/bin/bash
CMD=$(basename $0)
SED=$(which sed)
GREP=$(which grep)
ECHO=$(which echo)
CUT=$(which cut)
CAT=$(which cat)
import { decorate } from './private/utils';
// WIP: prototypical, might not be working at all, needs additional work!
function findSuperDesc(superklass, key)
{
let result;
let supklass = superklass;
while (supklass.prototype)
{
if (Object.hasOwnProperty(supklass, key))
@silkentrance
silkentrance / gist:8133476645f9ce7bcf5b
Last active February 22, 2016 23:28
Example impl
import util from 'util';
function hypotheticalDecoratorThatMerges(target, key, descriptor)
{
let result = descriptor;
if ('get' in descriptor || 'set' in descriptor)
{
const desc = {};
Object.keys(descriptor).forEach(
@silkentrance
silkentrance / cli.js
Last active November 7, 2016 18:45
Miscellaneous PEGJS grammars, a CLI testing frontend and input data
#!/usr/bin/env /usr/bin/node
// usage ./cli [grammar.js] unit.ypo
// default grammar is ypo.js
var fs = require('fs');
var path = require('path');
var util = require('util');
@silkentrance
silkentrance / auth.py
Created May 15, 2015 13:35
Django 1.8.1 Auth Integration for Mongoengine <0.9.0
# adapted from django.contrib.auth
#
# simply import the here provided login() to make mongoengine work with Django 1.8.1
from django.conf import settings
from django.middleware.csrf import rotate_token
from django.utils.translation import LANGUAGE_SESSION_KEY
from django.contrib.auth.signals import user_logged_in, user_logged_out, user_login_failed
from django.contrib.auth import SESSION_KEY, BACKEND_SESSION_KEY, HASH_SESSION_KEY, REDIRECT_FIELD_NAME, get_user_model, load_backend
from bson import ObjectId