Skip to content

Instantly share code, notes, and snippets.

View gnerkus's full-sized avatar
🎯
Focusing

gnerkus

🎯
Focusing
  • 22:24 (UTC +02:00)
View GitHub Profile
@gnerkus
gnerkus / constructor_check.js
Created September 22, 2015 07:13
Verify object instance has instance attributes defined using Esprima
// This file is to executed in a Nodejs environment.
// `node constructor_check.js`
'use strict';
// You'll need to install the 'esprima', 'estraverse' and 'lodash' modules via npm.
var esprima = require('esprima');
var estraverse = require('estraverse');
var fs = require('fs');
var path = require('path');
var _ = require('lodash');
@gnerkus
gnerkus / Recursive Find
Created February 10, 2013 04:06
Search for a character in an iterable and return an index of all occurrences of that character.
def recursvfind (search, target, start=0, pos=[]):
current_pos = str(target).find(search, start)
if current_pos < 0:
return pos
else:
return recursvfind(search, target, current_pos + 1, pos + [current_pos])