Skip to content

Instantly share code, notes, and snippets.

@mdonkers
mdonkers / server.py
Last active April 25, 2024 10:25
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@PeterAttardo
PeterAttardo / dim_calendar.hql
Last active November 16, 2022 08:14
Create calendar dimension table in hive query language (HQL)
set hivevar:start_date=0000-01-01;
set hivevar:days=1000000;
set hivevar:table_name=[INSERT YOUR TABLE NAME HERE];
-- If you are running a version of HIVE prior to 1.2, comment out all uses of date_format() and uncomment the lines below for equivalent functionality
CREATE TABLE IF NOT EXISTS ${table_name} AS
WITH dates AS (
SELECT date_add("${start_date}", a.pos) as date
@wdullaer
wdullaer / install.sh
Last active April 2, 2024 20:33
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
@debasishg
debasishg / gist:8172796
Last active March 15, 2024 15:05
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&amp;rep=rep1&amp;t
@Pyrolistical
Pyrolistical / functions.js
Last active December 28, 2017 04:10 — forked from RedBeard0531/functions.js
Mongo map reduce functions to calculate sum, min, max, count, average, population variance, sample variance, population standard deviation, sample standard deviation Public Domain License
function map() {
emit(1, {
sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count: 1,
diff: 0
});
}
@jpountz
jpountz / Recover.java
Last active December 22, 2015 10:48
File to restore a corrupted segment if the stored fields are not corrupted.
// Set codec, dir and segmentName accordingly to the segment you are trying to restore
Codec codec = new Lucene42Codec();
Directory dir = FSDirectory.open(new File("/tmp/test"));
String segmentName = "_0";
IOContext ioContext = new IOContext();
SegmentInfo segmentInfos = codec.segmentInfoFormat().getSegmentInfoReader().read(dir, segmentName, ioContext);
Directory segmentDir;
if (segmentInfos.getUseCompoundFile()) {
segmentDir = new CompoundFileDirectory(dir, IndexFileNames.segmentFileName(segmentName, "", IndexFileNames.COMPOUND_FILE_EXTENSION), ioContext, false);
@miketheman
miketheman / zook_grow.md
Created July 22, 2013 21:36
Adding nodes to a ZooKeeper ensemble

Adding 2 nodes to an existing 3-node ZooKeeper ensemble without losing the Quorum

Since many deployments may start out with 3 nodes and so little is known about how to grow a cluster from 3 memebrs to 5 members without losing the existing Quorum, here is an example of how this might be achieved.

In this example, all 5 nodes will be running on the same Vagrant host for the purpose of illustration, running on distinct configurations (ports and data directories) without the actual load of clients.

YMMV. Caveat usufructuarius.

Step 1: Have a healthy 3-node ensemble

@nathanlws
nathanlws / CustomCase.java
Last active December 18, 2015 14:29
FoundationDB SQL Parser IdentifierCase
//
// See: https://github.com/foundationdb/sql-parser
//
import com.foundationdb.sql.parser.*;
import com.foundationdb.sql.parser.SQLParserContext.*;
public class CustomCase {
public static class ColumnNamePrinter implements Visitor {
@Override
@dadoonet
dadoonet / backup.sh
Created December 26, 2012 14:50
Backup Elasticsearch node
# Script to be placed in elasticsearch/bin
# Launch it from elasticsearch dir
# bin/backup indexname
# We suppose that data are under elasticsearch/data
# It will create a backup file under elasticsearch/backup
if [ -z "$1" ]; then
INDEX_NAME="dummy"
else
INDEX_NAME=$1
@radu-gheorghe
radu-gheorghe / log_backup.bash
Created July 26, 2012 08:31
Optimize&Backup Elasticsearch index. And restore.
#!/usr/bin/env bash
###############FUNCTIONS############
function prepare {
#optimize the index
echo -n "Optimizing index $INDEX_NAME..."
curl -XPOST "$ADDRESS/$INDEX_NAME/_optimize" 2>/dev/null| grep 'failed":0' >/dev/null
if [ $? -eq 0 ]; then
echo "done"