Skip to content

Instantly share code, notes, and snippets.

View haizaar's full-sized avatar

Zaar Hai haizaar

View GitHub Profile
haizaar /
Last active September 16, 2022 21:09
APIConnector for thread-safe google api python client
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any, Callable, Hashable, List, Optional
import google.auth
import httplib2
import structlog
from google_auth_httplib2 import AuthorizedHttp
from googleapiclient.http import HttpRequest
haizaar /
Last active July 29, 2022 21:23
Google Auth Utils for Directory API
import subprocess
import warnings
from typing import List, Optional
import google.auth
import google.auth.iam
import google.oauth2.credentials
import structlog
from google.auth.credentials import Credentials
from google.auth.transport import requests
haizaar /
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
haizaar / bench.lua
Last active May 11, 2019 14:40
Lua "class" performance
-- Plain function for baseline
local func = function(x)
return x
-- Closure
local IClass = function(id)
local foo = function()
return id
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 \
ENV PYROOT /pyroot
$ python
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"
[('logOctets', False, 'WampWebSocketClientFactory'),
('logFrames', False, 'WampWebSocketClientFactory'),
('trackTimings', False, 'WampWebSocketClientFactory'),
('utf8validateIncoming', True, 'WampWebSocketClientFactory'),
('applyMask', True, 'WampWebSocketClientFactory'),
haizaar / Dockerfile
Last active September 21, 2018 08:41
Wiola minimal setup
# NOTE: This is a really quick & dirty version
FROM openresty/openresty:
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"]
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 / Dockerfile - mem loader
Last active February 12, 2020 04:24
Simple Memory loader in Python for Kebernetes GKE
FROM python:3.5-alpine
CMD python -u
haizaar / Dockerfile - cpu loader
Last active May 24, 2021 06:08
Simple CPU loader in Python for Kebernetes GKE
FROM python:3.5-alpine
CMD nice -n ${NICENESS:-0} python -u