Skip to content

Instantly share code, notes, and snippets.

View aih's full-sized avatar

Ari Hershowitz aih

View GitHub Profile
@aih
aih / safe-html.pipe.ts
Created August 23, 2019 21:21 — forked from zomdar/safe-html.pipe.ts
safeHtml pipe
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
@Pipe({
name: 'safeHtml'
})
export class SafeHtmlPipe implements PipeTransform {
constructor(private _sanitizer:DomSanitizer) {}
@aih
aih / happy_git_on_osx.md
Created March 10, 2017 20:24 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

@aih
aih / permutations.js
Last active January 27, 2017 06:57 — forked from wassname/permutations.js
Combinatorics permutatons and product in javascript using lodash.js (like python's itertools)
/**
* Lodash mixins for combinatorics
* Inspired by python itertools: https://docs.python.org/2.7/library/itertools.html
*
* Usage:
* permutations([0,1,2],2) // [[0,1],[0,2],[1,0],[1,2],[2,0],[2,1]]
* combinations([0,1,2],2) // [[0,1],[0,2],[1,2]]
* combinations_with_replacement([0,1,2],2)// [[0,0],[0,1],[0,2],[1,1],[1,2],[2,2]]
* product([0,1,2],[0,1,2]) // [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]
*
@aih
aih / update-bundles.sh
Last active November 17, 2019 06:24 — forked from janlay/update-repos.sh
Update all Vim bundles for Pathogen
#/bin/sh
cd ~/.vim/bundle
for i in `\ls -p -d */`; do
cd "$i"
echo "Updating $i..."
git pull --recurse-submodules | grep -v 'Already up-to-date' | sed 's/^/ /'
[ -f .git/.gitmodules ] && git submodule update | sed 's/^/ /'
cd ..
done
@aih
aih / string_search.js
Created October 21, 2015 06:17 — forked from amoilanen/string_search.js
Rabin-Karp Algorithm for Searching Strings Implemented in JavaScript
function simpleSearch(text, str) {
var matches = [];
for (var i = 0; i <= text.length; i++) {
if (matchesAtIndex(i, text, str)) {
matches.push(i);
}
}
return matches;
}
@aih
aih / gist:b2e9bc6db0f71486edc4
Created October 5, 2015 04:39 — forked from jrotello/gist:8873462
Powershell helper to ease Elasticsearch interaction without curl
function Invoke-Elasticsearch {
[CmdletBinding()]
Param(
[Uri]$Uri,
[Microsoft.PowerShell.Commands.WebRequestMethod]$Method = 'Get',
$Body = $null,
[PSCredential]$Credential
)
$headers = @{}
  1. Copy wfastcgi.py to c:\inetpub\wwwroot
  2. Run _appcmd.bat (or paste it into a cmd.exe window).
  3. Create a new site in IIS and copy/paste main.py into its root directory.

Note: I've added one line (#375) that appends the physical path to sys.path, because the PYTHONPATH cannot be easily overridden via web.config for multiple sites. Otherwise, the wfastcgi.py is identical to the Python Tools for Visual Studio v2.0 alpha at http://pytools.codeplex.com/releases

@aih
aih / gpolocator.py
Created August 4, 2012 05:50 — forked from twneale/gpolocator.py
Getting GPO Locator data into a more usable form
# -*- coding: utf-8 -*-
'''
Usage:
>>> f = open('usc08.10')
>>> x = getlines(f)
>>> x.next()
GPOLocatorLine(code='F', arg='5800', data=u'\r\n')
>>> print x.next().data
TITLE 8–ALIENS AND NATIONALITY
@aih
aih / Citation resolver
Created May 15, 2011 04:40 — forked from mpoulshock/Citation resolver
Legal citation resolver / redirector
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4206
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
@aih
aih / gist:972890
Created May 15, 2011 04:37 — forked from mpoulshock/gist:963725
Transforms legal citations into hyperlinks
// ==UserScript==
// @name Jureeka
// @namespace http://www.jureeka.org
// @description Turns legal citations in webpages into hyperlinks that direct you to online legal source material.
// ==/UserScript==
/*
Warnings:
* This triggers a memory leak bug in Firefox.