Navigation Menu

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 / 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 / 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 / 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 / wordcloud.ipynb
Created September 3, 2019 05:20
wordcloud
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lxneng
lxneng / make-qcloud-signature.py
Created August 27, 2019 05:27
腾讯云API接口鉴权
import hmac
import base64
def make_qcloud_signature(req_params: dict, req_host: str, req_path: str,
req_method: str, secret_key: str) -> str:
""" Make QCloud API Signature
https://cloud.tencent.com/document/product/271/2053
params example:
```
@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 / shuffe-array.js
Created July 15, 2019 02:22
shuffe array
function shuffle(a) {
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
return a;
};
@lxneng
lxneng / axiosHttpsProxyAgent.js
Created July 12, 2019 06:11
axios over https proxy agent
const axios = require('axios');
const httpsProxyAgent = require('https-proxy-agent');
axios({
url: 'https://mp.weixin.qq.com/s?__biz=MjM5MjA5NTk0MA==&mid=2652614878&idx=1&sn=2f04cadcc65d38767f8b549f454c895e&chksm=bd449b758a3312631e1eb6a02f9c285b8b90871a18bd7f28c7cfc17bd820d8dbdc06b9669cfa&scene=27#wechat_redirect',
httpsAgent: new httpsProxyAgent('http://61.128.208.94:3128')
}).then((res) => {
console.log(res.data);
}).catch((err) => {
console.log(err);
# 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 / _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)