Skip to content

Instantly share code, notes, and snippets.

@abhilater
abhilater / pig.txt
Created October 25, 2017 09:24
[pig snippets] #pig
pig -x local -f profiles.pig > acompli-hbase.txt
cat acompli-hbase.txt |cut -d',' -f1-3 | cut -d'(' -f 2 > acompli-hbase-final.txt
HADOOP_USER_NAME=cloud_analytics pig -P cloud_analytics_pig.properties -m cloud_analytics_pig.param -f backfill_agentHoldingTimeAggregate.pig -p month_string=
HADOOP_USER_NAME=cloud_analytics pig -P cloud_analytics_pig.properties -m cloud_analytics_pig.param -f dau-hugegames.pig -useHCatalog
hdfs dfs -ls /analytics/events/event_date=2017-09-08/action_type=a
mapred job -kill job_1486125356459_708807
@abhilater
abhilater / ansible.txt
Created October 25, 2017 07:06
[Ansible snippets] #ansible
ansible-playbook -i hosts verify.yml
@abhilater
abhilater / ssh.txt
Last active February 12, 2019 06:38
[SSH snippets] #ssh
ssh-add -K ~/.ssh/id_rsa
ssh -L 9098:localhost:9097 sandbox.hortonworks.com -p 2222 -l root
ssh -L 4098:localhost:4098 abhishekgupta@hdp01-cli01
ssh -A jump.p.helpshift.com ssh -A hdp01-cli01 cat /home/abhishekgupta/dataplat-2716.csv/csr-2716.csv > csr-2716.csv
rsync -avz -e "ssh -p 2222" --exclude 'target/*' --exclude '.git*' bitter root@127.0.0.1:/root/abhishek/bitter
mvn clean package -DskipTests -Pbackfill && hdfs dfs -put -f target/jswine/jswine.jar
@abhilater
abhilater / hdfs-python-reporter.py
Created July 12, 2017 18:58
Python script that works on HDFS files and creates nice reports
#!/usr/bin/python
#import pydoop.hdfs as hdfs
import subprocess
import ast
import re
import csv
#with hdfs.open('/adhoc/faq-suggestion-report-all/daily/dt=2017-07-03/B/') as f:
# for line in f:
@abhilater
abhilater / date-iterator.sh
Created July 12, 2017 18:56
Shell script that iterates over date and runs jobs
#!/bin/bash
d=2017-07-03
while [ "$d" != 2017-07-12 ]; do
echo "Running for date:" $d
echo -e '\n\n'
#curl -L http://google.com?q=$d
HADOOP_USER_NAME=hdfs yarn jar /home/abhishekgupta/gerrit/emrgent/target/emrgent-0.1.1-standalone.jar prod daily sdk_q A dt=$d
HADOOP_USER_NAME=hdfs yarn jar /home/abhishekgupta/gerrit/emrgent/target/emrgent-0.1.1-standalone.jar prod daily sdk_q B dt=$d
d=$(date -I -d "$d + 1 day")
echo -e '\n\n'
@abhilater
abhilater / sxml.clj
Created June 16, 2017 10:20
DSL written in clojure similar to the S-XML
(ns demo.dsl.sxml)
(defn format-attrs-map [attrs-map]
(->> (seq attrs-map)
(map (fn [[key val]] (str (name key) ":" "'" val "'")))
(clojure.string/join " ")))
(defn generate-html [tag-name attrs body]
@abhilater
abhilater / clojure-oop
Last active June 9, 2017 05:45
All about Clojure OOP
https://github.com/abhilater/clojure-type-selection-flowchart
https://stackoverflow.com/questions/8614734/how-do-i-implement-a-java-interface-in-clojure
https://stackoverflow.com/questions/5821892/why-should-i-use-reify-instead-of-proxy-in-clojure
https://groups.google.com/forum/#!topic/clojure/WIIcvsYLzh0
AOP
====
https://stackoverflow.com/questions/5573418/aspect-oriented-programming-in-clojure
https://github.com/technomancy/robert-hooke
https://groups.google.com/forum/#!topic/clojure/Wsc6du1VxEs
https://stackoverflow.com/questions/2563632/how-can-i-merge-two-commits-into-one
@abhilater
abhilater / with-local-redefs.clj
Created June 5, 2017 13:18 — forked from gfredericks/with-local-redefs.clj
thread-local version of with-redefs
(defn with-local-redefs-fn
[a-var its-new-value func]
(cast clojure.lang.IFn @a-var)
(alter-meta! a-var
(fn [m]
(if (::scope-count m)
(update-in m [::scope-count] inc)
(assoc m
::scope-count 1
::thread-local-var (doto (clojure.lang.Var/create @a-var)
@abhilater
abhilater / n-primes.clj
Created May 18, 2017 14:25
Written a Clojure lazy-seq function to generate n prime numbers. It generates .5 million prime numbers in 20 secs
;; Clojure lazy-seq function to generate n prime numbers.
;; It generates .5 million prime numbers in 20 secs using
;; the naive non-sieve algo
;; Author: Abhishek Gupta (@abhilater)
(defn n-primes
[]
(filter (fn [num]
(loop [end (int (Math/sqrt num)), div 2, re (rem num div)]
(cond