Skip to content

Instantly share code, notes, and snippets.

View imamdigmi's full-sized avatar
😐
Focusing

Imam Digmi imamdigmi

😐
Focusing
View GitHub Profile
@imamdigmi
imamdigmi / list-chunks.py
Created June 11, 2020 06:27
Python Chunks Array Size
def chunks(lst, n):
"""Yield successive n-sized chunks from lst."""
for i in range(0, len(lst), n):
yield lst[i:i + n]
@imamdigmi
imamdigmi / logic_cheatseet.py
Last active March 12, 2020 14:16
Python Logic Cheatseet
def fun_max(a):
c = a[0]
for i in a:
if c < i:
c = i
return c
def fun_min(a):
c = a[0]
@imamdigmi
imamdigmi / init.vim
Created November 20, 2019 05:38 — forked from benawad/init.vim
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
"Plug 'tsony-tsonev/nerdtree-git-plugin'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
@imamdigmi
imamdigmi / airflow-k8s-executor-minikube-helm.md
Created June 26, 2019 16:11 — forked from kppullin/airflow-k8s-executor-minikube-helm.md
Airflow w/ kubernetes executor + minikube + helm

Overview

The steps below bootstrap an instance of airflow, configured to use the kubernetes airflow executor, working within a minikube cluster.

This guide works with the airflow 1.10 release, however will likely break or have unnecessary extra steps in future releases (based on recent changes to the k8s related files in the airflow source).

Prerequisites

  • Docker installed
  • Minikube installed and started
@imamdigmi
imamdigmi / pg_flatten_json.sql
Created February 19, 2019 12:49
Flattening json data in PostgreSQL
create or replace function create_jsonb_flat_view
(table_name text, regular_columns text, json_column text)
returns text language plpgsql as $$
declare
cols text;
begin
execute format ($ex$
select string_agg(format('%2$s->>%%1$L "%%1$s"', key), ', ')
from (
select distinct key
import pytz
from pytz import timezone
from dateutil import parser
def date_format(d):
"""Date format ISO 8601"""
if d is None or d == "":
return None
import os
import csv
import json
import pytz
from pytz import timezone
from datetime import datetime
from dateutil import parser
@imamdigmi
imamdigmi / airflow-dag-csv-to-mysql.py
Created January 15, 2019 15:46
Airflow Ftp CSV to SQL
"""
Code that goes along with the Airflow tutorial located at:
https://github.com/airbnb/airflow/blob/master/airflow/example_dags/tutorial.py
"""
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.operators.generic_transfer import GenericTransfer
from airflow.contrib.hooks import FTPHook
from airflow.hooks.mysql_hook import MySqlHook
yum install python-setuptools -yy
easy_install supervisor
echo_supervisord_conf > /etc/supervisord.conf
mkdir /etc/supervisord.d/
[include]
files = /etc/supervisord.d/*.conf
[inet_http_server]
port = *:9001
Yogyakarta 130
Jakarta Selatan 193
Semarang 109
Bandung 170
Malang 1343
Bogor 980
Samarinda 30
Bekasi 43
Jambi 541
Palangkaraya 312