Skip to content

Instantly share code, notes, and snippets.

View xeraa's full-sized avatar
🥑
Developer

Philipp Krenn xeraa

🥑
Developer
View GitHub Profile
@xeraa
xeraa / helper.rb
Created August 4, 2015 23:48
Middleman: Fully automated alternate language links
# Returns a hash of localized paths for a given page
def localized_paths_for(page)
localized_paths = {}
(langs).each do |locale|
# Loop over all pages to find the ones using the same templates (proxied_to) for each language
sitemap.resources.select do |resource|
if resource.proxied_to == page.proxied_to && resource.metadata[:options][:lang] == locale
localized_paths[locale] = resource.url
break
Verifying that +xeraa is my blockchain ID. https://onename.com/xeraa
GET /raffle/_search
{
"size": 1,
"query": {
"function_score": {
"functions": [
{
"random_score": { }
}
],
@xeraa
xeraa / union.json
Created January 13, 2017 23:51
Simulating a union query from SQL in Elasticsearch
DELETE my_index
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"type": {
"type": "keyword"
}
@xeraa
xeraa / issues.sh
Last active May 16, 2017 12:46
Export GitHub issues to Elasticsearch
#!/bin/bash
response=200
i=1
while [[ response -eq 200 ]]
do
curl -u '<username>:<token>' "https://api.github.com/repos/<account>/<repository>/issues?filter=all&state=all&per_page=100&page=${i}" > issues${i}.json
response=$(curl --write-out %{http_code} --silent --output /dev/null -u '<username>:<token>' "https://api.github.com/repos/<account>/<repository>/issues/$((i*100))")
((i++))
done
DELETE my_index
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"last_viewed": {
"type": "date",
"format": "dd/MM/YYYY||YYYY/MM/dd"
}
DELETE companies
PUT companies
{
"mappings": {
"company" : {},
"employee" : {
"_parent": {
"type": "company"
}
# Data
DELETE latest-connection
POST _bulk
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} }
{ "client": "10.10.10.10", "version": "1.3", "timestamp": "2018-05-01T12:10:30Z" }
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} }
{ "client": "20.20.20.20", "version": "1.5", "timestamp": "2018-05-01T12:10:30Z" }
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} }
{ "client": "10.10.10.10", "version": "1.4", "timestamp": "2018-05-02T12:10:30Z" }
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} }
@xeraa
xeraa / .env
Last active March 14, 2020 08:55
Minimal 3 node Elasticsearch + Kibana setup
ELASTIC_VERSION=5.6.9
#ELASTIC_VERSION=6.3.0
@xeraa
xeraa / .env
Last active January 17, 2020 17:32
Docker: Kibana + Elasticsearch with Stempel, Phonetic, and Language detection
ELASTIC_VERSION=6.3.0