Skip to content

Instantly share code, notes, and snippets.

@konradkonrad
konradkonrad / template_test.sh
Last active August 29, 2015 14:05
multi-language index mappings via templates POC
#!/bin/sh
# This tries to use index templates and dynamic_templates in order to define a
# 'DRY' multi language index-mapping (index per language).
# The 'general' template defines all field mappings (mostly via dynamic_templates) and
# their analyzers (which are underspecified on this level).
# The language templates ('de') do instantiate the the language specific analyzers
# and match the language suffix.
if [ -z "$ES" ]; then
@konradkonrad
konradkonrad / es_features.py
Last active January 25, 2022 23:52
tfidf from elasticsearch
import elasticsearch
from math import log
def tfidf_matrix(es, index, doc_type, fields, size=10, bulk=500, query=dict(match_all=[])):
"""Generate tfidf for `size` documents of `index`/`doc_type`.
All `fields` need to have the mapping "term_vector": "yes".
This is the consuming version (i.e. get everything at once).
:param es: elasticsearch client
@konradkonrad
konradkonrad / bad-mapping.sh
Created April 7, 2015 11:30
Elasticsearch silently ignores mis-structured mapping
curl -XDELETE localhost:9200/mytest
curl -XPUT localhost:9200/mytest
curl -XPUT localhost:9200/mytest/t1/_mapping -d '{
"t1": {
"_source": {"enabled": false},
"properties": {
"_all": {"enabled": false},
"field1": {"type": "string"},
@konradkonrad
konradkonrad / logstash.conf
Last active August 29, 2015 14:18
Setup plugin sketch
input {
setup {
ns => "connection"
params => {
host => "127.0.0.1"
port => 6666
username => "user"
password => "the pwd"
}
}
@konradkonrad
konradkonrad / README.md
Last active October 27, 2015 16:34
How to run a private pyethapp testcluster with docker-compose

Sometimes you maybe want to run your own little ethereum network. This is how you do it:

PREREQUISITES

  • install docker
  • install docker-compose
  • download docker-compose.yml

WHAT'S IN THE BOX?

The docker-compose.yml defines four services, which can start 4 slightly different configurations of pyethapp.

@konradkonrad
konradkonrad / .gitignore
Created October 23, 2015 11:25 — forked from karmi/.gitignore
Example Nginx configurations for Elasticsearch
nginx/
!nginx/.gitkeep
!nginx/logs/.gitkeep
src/
tmp/
contract Faucet {
address owner;
uint256 sendAmount;
mapping (address => uint) lastSent;
uint blockLimit;
function Faucet(){
owner = msg.sender;
sendAmount = 1000000000000000000;
blockLimit = 5;
}
@konradkonrad
konradkonrad / solc
Last active March 5, 2020 06:03
solc from docker (sort of)
#!/usr/bin/env bash
# Usage:
# ./solc [options] inputfile > outfile
# Notes:
# - file i/o is limited to the current directory
# - this works with the pyethereum solc_wrapper
docker run -i --rm --user $(id -u):$(id -g) -v $(pwd):/tmp --workdir /tmp ethereum/solc:0.4.18 $@
@konradkonrad
konradkonrad / 01-esc-dot.py
Last active September 14, 2016 13:44
restore yank-last-arg in ipython 5
# ~/.ipython/profile_default/startup/01-esc-dot.py
from IPython import get_ipython
from prompt_toolkit.enums import DEFAULT_BUFFER
from prompt_toolkit.keys import Keys
from prompt_toolkit.filters import HasFocus, HasSelection, ViInsertMode, EmacsInsertMode
ip = get_ipython()
insert_mode = ViInsertMode() | EmacsInsertMode()
@konradkonrad
konradkonrad / tester_dump.py
Created September 7, 2016 12:49
Create genesis['alloc'] dump of predeployed contracts with (py)ethereums `tester.py`
#!/usr/bin/env python
import os
import sys
import json
from ethereum import tester
from ethereum.utils import remove_0x_head
def strip_0x(value):
if isinstance(value, basestring):