Skip to content

Instantly share code, notes, and snippets.

herrbuerger

Block or report user

Report or block herrbuerger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:35707b81f063b0c53aaa851b23d2f15d
### Keybase proof
I hereby claim:
* I am herrbuerger on github.
* I am herrbuerger (https://keybase.io/herrbuerger) on keybase.
* I have a public key ASDehSwsfC_aKN2WUeEHyWdANSMW8ppk7RjIDs8tFXekTQo
To claim this, I am signing this object:
@herrbuerger
herrbuerger / postgres-cheatsheet.md
Created Dec 8, 2016 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet
View postgres-cheatsheet.md

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

@herrbuerger
herrbuerger / _euclidean.c
Created Jun 1, 2014
Squared euclidean distance calculation (C extension for Python)
View _euclidean.c
#include <Python.h>
#include <numpy/arrayobject.h>
#include "euclidean.h"
/* Docstrings */
static char module_docstring[] =
"This module provides an interface for calculating squared euclidean distance";
static char euclidean_docstring[] =
"Calculate the squared euclidean distance of two 128-dimensional vectors";
View gist:6cbeada92901a282c957
from annoy import AnnoyIndex
a = AnnoyIndex(3)
a.add_item(10, [1, 0, 0])
a.add_item(11, [0, 1, 0])
a.add_item(13, [0, 0, 1])
a.build(-1)
print a.get_nns_by_item(13, 10)
print a.get_nns_by_item(1, 10)
View gist:e4452d55ffb03a53d423
from annoy import AnnoyIndex
index = AnnoyIndex(1)
for x in range(10000):
id = "%d000%d" % (x,x)
index.add_item(int(id),[x])
View gist:5f22ee159d0df800c844
48000693
49000693
50000693
51000693
52000693
53000693
54000693
55000693
56000693
57000693
@herrbuerger
herrbuerger / gist:10961577
Last active Oct 28, 2015
Rotating snapshots for Elasticsearch
View gist:10961577

Rotationg snapshots for Elasticsearch (poor-man's version)

This is a very basic method to do rotating snapshots for Elasticsearch. For this to work you will need to have jq installed (http://stedolan.github.io/jq/).

PLEASE, PLEASE, PLEASE don't put this blindly in your commandline and execute it :)

curl -s -S -XGET "localhost:9200/_snapshot/my_s3_repository/_all?pretty=true" | jq '.snapshots[] | .snapshot + " " + .end_time' | sed 's/^.\(.*\).$/\1/' | sort -k 2 -r | awk '{ if (NR > 1) { system("curl -XDELETE " "localhost:9200/_snapshot/my_s3_repository/"$1) } } END { system("curl -XPUT " "localhost:9200/_snapshot/my_s3_repository/`date +\%s`") }'

Details

View gist:9366299
from math import sqrt
def confidence(ups, downs):
n = ups + downs
if n == 0:
return 0
z = 1.96 #1.96 = 95%
phat = float(ups) / n
View gist:9249908
➜ sample imagedups . --search -f 92bc12786d430083be1e166a2174b4888ba0b4ba.jpg
92bc12786d430083be1e166a2174b4888ba0b4ba.jpg
Traceback (most recent call last):
File "/usr/local/bin/imagedups", line 228, in <module>
prog.main()
File "/usr/local/bin/imagedups", line 60, in main
self.cmd_search()
File "/usr/local/bin/imagedups", line 90, in cmd_search
self.compare_with_db(hashdb, self.args.samplefile)
File "/usr/local/bin/imagedups", line 193, in compare_with_db
View gist:7009531
<context-param>
<param-name>net.myrrix.web.InitListener.USER_NAME</param-name>
<param-value>admin</param-value>
</context-param>
<context-param>
<param-name>net.myrrix.web.InitListener.PASSWORD</param-name>
<param-value>password</param-value>
</context-param>
You can’t perform that action at this time.