Skip to content

Instantly share code, notes, and snippets.

View haizaar's full-sized avatar
💭
Coding...

Zaar Hai haizaar

💭
Coding...
View GitHub Profile
@haizaar
haizaar / gist:4125404
Created November 21, 2012 15:22 — forked from clintongormley/gist:4096675
Nested documents

Create an index with a nested mapping:

curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1'  -d '
{
   "mappings" : {
      "test" : {
         "properties" : {
            "title" : {
               "type" : "string"

},

@haizaar
haizaar / 1. Execution results CPython 3.4.2
Last active August 29, 2015 14:17
dictionary tree traversal with path keeping
inline: 0.388133 seconds
iterate_tree: 0.772798
iterate_tree2: 0.707333
iterate_tree3: 0.564626
iterate_tree3_noyield: 0.498388
iterate_tree3_nofeedback: 0.353944
iterate_tree5: 0.650102
iterate_tree5_noyield: 0.566557
iterate_tree5_nofeedback: 0.435601
iterate_tree6: 0.562908
@haizaar
haizaar / Dockerfile - cpu loader
Last active May 24, 2021 06:08
Simple CPU loader in Python for Kebernetes GKE
FROM python:3.5-alpine
ADD https://gist.github.com/haizaar/91469f5c4dfdef1f1965/raw/702e42eefa28d2b81ffd09990edf61035f51638f/cpu_loader.py cpu_loader.py
CMD nice -n ${NICENESS:-0} python -u cpu_loader.py
@haizaar
haizaar / Dockerfile - mem loader
Last active February 12, 2020 04:24
Simple Memory loader in Python for Kebernetes GKE
FROM python:3.5-alpine
ADD https://gist.githubusercontent.com/haizaar/607f43e282c4e0f8737a/raw/1145c89b5aa34e2ec7afe32fb9d0e27661c7debd/mem_loader.pyy mem_loader.py
CMD python -u mem_loader.py
@haizaar
haizaar / nginx-ip-watch
Last active April 24, 2016 08:49
Reverse proxy to Kubernetes cluster NodePort through nginx
#!/usr/bin/env python
import os
import subprocess
import argparse
import json
from oauth2client.client import GoogleCredentials
from googleapiclient import discovery
@haizaar
haizaar / Dockerfile
Last active September 21, 2018 08:41
Wiola minimal setup
# NOTE: This is a really quick & dirty version
FROM openresty/openresty:1.13.6.2-0-alpine-fat
RUN apk add --no-cache cmake openssl-dev git
RUN /usr/local/openresty/luajit/bin/luarocks install wiola 0.9.1-2
CMD ["/usr/local/openresty/bin/openresty"]
$ python bug-subscribe-and-do-nothing.py
2019-01-15T00:14:01 Entering re-connect loop
2019-01-15T00:14:01 trying transport 0 using connect delay 0
2019-01-15T00:14:01 connecting once using transport type "websocket" over endpoint "tcp"
2019-01-15T00:14:02
[('logOctets', False, 'WampWebSocketClientFactory'),
('logFrames', False, 'WampWebSocketClientFactory'),
('trackTimings', False, 'WampWebSocketClientFactory'),
('utf8validateIncoming', True, 'WampWebSocketClientFactory'),
('applyMask', True, 'WampWebSocketClientFactory'),
@haizaar
haizaar / Dockerfile
Created January 18, 2019 00:49
Crossbar Dockerfile alphine
FROM python:3.7.2-alpine AS builder
RUN apk add --no-cache --virtual .build-deps \
build-base \
libffi-dev \
openssl-dev \
linux-headers
ENV PYROOT /pyroot
ENV PATH $PYROOT/bin:$PATH
@haizaar
haizaar / bench.lua
Last active May 11, 2019 14:40
Lua "class" performance
-- Plain function for baseline
local func = function(x)
return x
end
-- Closure
local IClass = function(id)
local foo = function()
return id
end
@haizaar
haizaar / create-composite-type.py
Created August 26, 2019 14:44
A script to create multi-file GCP Deployment Manager composite type
import json
import time
import click
import googleapiclient.discovery
import googleapiclient.errors
@click.command("create")
@click.argument("name")