Skip to content

Instantly share code, notes, and snippets.

@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])
@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 / CreatingIdentityTables.cs
Created October 21, 2024 09:57
Migration to add ASP NET Identity relations
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace streak.Migrations
{
/// <inheritdoc />
public partial class CreatingIdentityTables : Migration
{