Skip to content

Instantly share code, notes, and snippets.

ebongzzang /
Last active Feb 5, 2020
print all dates string between startdate and enddate in mac os
function print_formatted() {
res=`date -j -f %Y-%m-%d $1 +%Y-%m-%d`
echo $res
from itertools import chain
import numpy as np
from collections import Counter
from multiprocessing import cpu_count, Pool
def a(weights):
w_sum = np.sum(weights)
value = np.random.randint(w_sum, size=1)[0]
# Register your models here.
import inspect
import sys
from cytoolz import *
from django.contrib import admin
from guardian.admin import GuardedModelAdmin
from .models import *
ebongzzang / ecr-cronjob.yaml
Created Feb 22, 2019
kubernetes ecr token refresh script (all namespace)
View ecr-cronjob.yaml
# before apply below script, run command
# kubectl create clusterrolebinding ecr-cluster-rule --clusterrole=cluster-admin --serviceaccount=default:default
apiVersion: batch/v1beta1
kind: CronJob # Tell kuber' that this is a cronjob
name: ecr-puller # Name of the job ,can be anything
namespace: default
concurrencyPolicy: Allow
ebongzzang /
Last active Nov 5, 2019
get_object_list_from_bucket using boto3
import json
import re
from io import BytesIO, StringIO
from typing import List
import requests
import bs4
import boto3
s3 = boto3.client('s3')
ebongzzang /
Created Dec 12, 2018
pyarrow insert_df_to_plasma
import numpy as np
import pandas as pd
import pyarrow as pa
from pyarrow import plasma
def insert_df_to_plasma(client, df: pd.DataFrame, key=plasma.ObjectID(np.random.bytes(20))) -> plasma.ObjectID:
record_batch = pa.RecordBatch.from_pandas(df)
object_id = key
def create_yearmonth_list(start_year:int, end_year: int):
start_at = start_year * 100
end_at = end_year - start_year
for year in range(0,end_at+1):
year_acc = year*100
start = start_at + year_acc
for month in range(1,13):
yyyymm = start+month
ebongzzang / lsyncd.lua
Last active Oct 29, 2018
lsync example on mac os x
View lsyncd.lua
settings {
logfile = "/tmp/lsyncd.log",
statusFile = "/tmp/lsyncd.status",
nodaemon = true
sync {
targetdir = "/path/to/target",
ebongzzang /
Created Oct 4, 2018
nested list comprehesion, flatten and create dict from tuple list
subland_dict = {
'hello': ['hello1', 'hello2', 'hello3']
res = [[(y,k) for y in v] for k, v in subland_dict.items()]
# [[('hi1', 'hi'), ('hi2', 'hi'), ('hi3', 'hi')], [('hello1', 'hello'), ('hello2', 'hello'), ('hello3', 'hello')]]
merged = dict(list(itertools.chain.from_iterable(res)))
# {'hi1': 'hi', 'hi2': 'hi', 'hi3': 'hi', 'hello1': 'hello', 'hello2': 'hello', 'hello3': 'hello'}
ebongzzang /
Created Aug 9, 2018 — forked from PurpleBooth/
A template to make good

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.