Skip to content

Instantly share code, notes, and snippets.

Avatar

Ilya Shalyapin un1t

View GitHub Profile
View youtubePlaybackRate.js
/*
Youtube playback rate hotkeys:
Ctrl + UP
Ctrl + DONW
*/
function createPlaybackRateDisplay() {
var elem = document.createElement('span');
elem.style = 'position: fixed; left: 0; top: 0; z-index: 10000; background: #000; color: #fff; font-size: 32px;'
elem.setAttribute('id', 'paylbackRateDisplay')
View elasticsearch-roses.sh
# curl -XDELETE 'http://localhost:9200/test'
curl -XPUT 'http://localhost:9200/test' -d '
{
"analysis": {
"char_filter": {
"my_charfilter": {
"type": "mapping",
"mappings": ["Ё=>Е", "ё=>е"]
}
View elasticsearch nested
curl -XPUT 'http://localhost:9200/_bulk?pretty' -d '
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "1" } }
{ "title" : "The NoSQL database glut", "journal" : "2", "author": [{"title": "August S"}, {"title": "Weiss P L"}] }
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "2" } }
{ "title" : "Graph Databases Seen Connecting the Dots", "journal" : "1", "author": [{"title": "Weiss S"}] }
'
curl -XGET 'http://localhost:9200/test/_search?pretty' -d '{"query": {"match": {"author.title": {"query": "weiss s", "operator": "and"}}}}'
@un1t
un1t / RapidXmlExample.c
Created Nov 14, 2016 — forked from JSchaenzle/RapidXmlExample.c
RapidXml example parsing beer journal
View RapidXmlExample.c
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include "rapidxml-1.13/rapidxml.hpp"
using namespace rapidxml;
using namespace std;
@un1t
un1t / raw_prefetch_related.py
Created Nov 11, 2016
Django raw with prefetch_related
View raw_prefetch_related.py
@un1t
un1t / SIREn Join
Created Oct 22, 2016
SIREn Join Plugin for Elasticsearch Example
View SIREn Join
curl -XPUT 'http://localhost:9200/_bulk?pretty' -d '
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "1" } }
{ "title" : "The NoSQL database glut", "journal" : "2", "author": "1" }
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "2" } }
{ "title" : "Graph Databases Seen Connecting the Dots", "journal" : "1", "author": "2"}
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "3" } }
{ "title" : "How to determine which NoSQL DBMS best fits your needs", "journal" : "2", "author": "3" }
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "4" } }
{ "title" : "MapR ships Apache Drill", "journal" : "4", "author": "4" }
View django_bitfield.py
from django import forms
from django.db import models
class BitFieldWrapper:
def __init__(self, instance, field, value):
self.instance = instance
self.field = field
self.value = value
View gist:536f4391b6091097aae5e40b57e61f68
import gc
from more_itertools import chunked
from collections import defaultdict
def fetch_fk(fk_field, fields, objects):
assert 'id' in fields
if not objects:
return
@un1t
un1t / logging-settings.py
Created Jun 30, 2016
django logging settings
View logging-settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(process)d %(module)s %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
View elasticsearch.yml
cluster.name: mycluster
node.name: node-1
node.master: true
node.data: true
network.host: 0.0.0.0
transport.tcp.port: 9300
http.port: 9200