Skip to content

Instantly share code, notes, and snippets.

@LeiG
LeiG / .gcloud
Last active October 26, 2017 00:01
#!/bin/zsh
# gcloud-init initializes a Google dataproc cluster
# arguments:
# $1 jar
# $2 env
function gcloud-init () {
gcloud dataproc clusters create dp-$USER-$1-test \
--image-version 1.1 \
--num-workers 20 \
@LeiG
LeiG / .spacemacs
Last active August 19, 2018 16:47
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@LeiG
LeiG / python-impala.py
Last active September 7, 2018 07:43
Query impala using python
import yaml
import pyodbc
import impala.dbapi
import impala.util
with open('config.yaml', 'r') as f:
cfg = yaml.load(f)
# METHOD 1: using pyodbc to establish connection
connString = 'Driver=%s;Host=%s;Port=%d;Database=default; \
@LeiG
LeiG / python-RData.py
Last active April 8, 2022 14:06
Python and .RData files
import rpy2.robjects as robjects
import pandas.rpy.common as com
import pandas as pd
## load .RData and converts to pd.DataFrame
robj = robjects.r.load('test.RData')
# iterate over datasets the file
for sets in robj:
myRData = com.load_data(sets)
# convert to DataFrame