Skip to content

Instantly share code, notes, and snippets.

View aih's full-sized avatar

Ari Hershowitz aih

View GitHub Profile
@aih
aih / gist:a135c558c71600626838
Last active August 29, 2015 14:22
Celery with Flask on Windows -- Notes
Steps to run Celery with Flask on Windows
1. Install Celery and RabbitMQ as described here:
http://celery.readthedocs.org/en/latest/getting-started/first-steps-with-celery.html#first-steps
2. Run a celery worker with the following command, in the directory of the app:
>celery -A messaging.tasks worker --loglevel=info --pool=solo
3. To run this in the background, configure a Windows service as described here:
http://mrtn.me/blog/2012/07/04/django-on-windows-run-celery-as-a-windows-service/
@aih
aih / IIS Reverse Proxy for Elasticsearch
Created September 15, 2015 21:04
A sample web.config file with URL rewrite rules for Elasticsearch on IIS (Windows)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<remove name="ReverseProxyInboundRule1" />
<rule name="ReverseProxyInboundRule1" stopProcessing="false">
<match url="search/_search(.*)" />
<conditions />
<serverVariables />
@aih
aih / Analyze twice
Created September 16, 2015 20:20
Create an Elasticsearch mapping to analyze a field twice: once with an English analyzer (for flexible search) and once with a whitespace analyzer (for exact matches)
POST myindex
{"mappings":{
"mytype" : {
"properties" : {
"flex_docText" : { "type": "string",
"analyzer" : "english" },
"exact_docText" : { "type": "string",
"analyzer" : "whitespace" }
}
}
@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 = @{}
@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:32438649175190f8497e
Last active December 2, 2015 07:05
Straight line drawing using HTML5 Canvas (to select items in an adjacent column)
http://jsfiddle.net/gavvhzox/
<canvas id="c" width="50" height="500" style="border:1px solid #ccc"></canvas>
canvas.on('mouse:down', function(o){
isDown = true;
var pointer = canvas.getPointer(o.e);
var points = [ 10, pointer.y, 10, pointer.y ];
line = new fabric.Line(points, {
strokeWidth: 4,
fill: 'black',
stroke: 'black',
@aih
aih / kaballist
Created January 3, 2017 21:29
Calculate numeric value for English words
from functools import reduce
from string import ascii_lower as alphas
ALPHADICT = dict(zip(alphas,range(26)))
def kfun(iword):
return reduce(lambda x, y: x + ALPHADICT[y] ,list(iword),0)
@aih
aih / .vimrc
Last active January 7, 2017 09:34
".vimrc file
"Markdown to HTML
nmap <leader>md :%!/usr/local/bin/Markdown.pl --html4tags <cr></cr> </leader>
filetype off
call pathogen#infect()
syntax on
call pathogen#helptags()
filetype plugin indent on
@aih
aih / brew packages
Last active January 7, 2017 09:37
From `brew list` command
ant
autoconf
automake
bash
binutils
cairo
coreutils
cscope
diffutils
doxygen