Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
@lxneng
lxneng / _write_dataframe_to_csv_on_s3.py
Created December 27, 2018 06:06 — forked from jitsejan/_write_dataframe_to_csv_on_s3.py
Write a Pandas dataframe to CSV format on AWS S3.
import boto3
from io import StringIO
def _write_dataframe_to_csv_on_s3(dataframe, filename):
""" Write a dataframe to a CSV on S3 """
print("Writing {} records to {}".format(len(dataframe), filename))
# Create buffer
csv_buffer = StringIO()
# Write dataframe to buffer
dataframe.to_csv(csv_buffer, sep="|", index=False)
# List all tables:
select db_id, id, name, sum(rows) as mysum
from stv_tbl_perm where db_id = 100546
group by db_id, id, name order by mysum desc;
# list all running processes:
select pid, query from stv_recents where status = 'Running';
# describe table
select * from PG_TABLE_DEF where tablename='audit_trail';
@lxneng
lxneng / async-foreach.js
Created August 7, 2019 02:29 — forked from atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@lxneng
lxneng / disable.sh
Created December 20, 2019 08:05
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
@lxneng
lxneng / disable.sh
Created December 20, 2019 08:10 — forked from junkblocker/disable.sh
Disable bunch of #$!@ in Catalina
#!/bin/bash
if [[ "$(sw_vers -productVersion)" != 10\.15* ]]; then
echo "This is only meant to run on macOS 10.15.* Catalina" >&2
exit 1
fi
reply=
printf "Are you pretty damn sure you want to run this? (Yes/No) "
read -r reply
[[ $reply != Yes ]] && exit 1
@lxneng
lxneng / gist:9b0a1585e7e41c9fae067718024d1717
Created April 3, 2020 03:33 — forked from Frozenfire92/gist:3627e38dc47ca581d6d024c14c1cf4a9
Install Scala and SBT using apt-get on Ubuntu 16.04 or any Debian derivative using apt-get
## Java
sudo apt-get update
sudo apt-get install default-jdk
## Scala
sudo apt-get remove scala-library scala
sudo wget http://scala-lang.org/files/archive/scala-2.12.1.deb
sudo dpkg -i scala-2.12.1.deb
sudo apt-get update
sudo apt-get install scala
@lxneng
lxneng / StreamCatsToHBase.py
Created August 20, 2020 14:21 — forked from MallikarjunaG/StreamCatsToHBase.py
PySpark HBase and Spark Streaming: Save RDDs to HBase - http://cjcroix.blogspot.in/
1: import sys
2: import json
3: from pyspark import SparkContext
4: from pyspark.streaming import StreamingContext
5:
6:
7: def SaveRecord(rdd):
8: host = 'sparkmaster.example.com'
9: table = 'cats'
10: keyConv = "org.apache.spark.examples.pythonconverters.StringToImmutableBytesWritableConverter"
@lxneng
lxneng / LearnGoIn5mins.md
Created January 15, 2021 02:57 — forked from prologic/LearnGoIn5mins.md
Learn Go in ~5mins
@lxneng
lxneng / install-azkaban.md
Created January 19, 2021 05:54 — forked from greenqy/install-azkaban.md
install-azkaban.md
@lxneng
lxneng / sidekiq_cheat_sheet.md
Created November 16, 2021 07:10 — forked from wakproductions/sidekiq_cheat_sheet.md
Sidekiq Commands Cheat Sheet