Skip to content

Instantly share code, notes, and snippets.

View shuson's full-sized avatar
🎯
Focusing

Nevermoi shuson

🎯
Focusing
View GitHub Profile
#!/bin/bash
# function Extract for common file formats
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
else
if [ -f "$1" ] ; then
NAME=${1%.*}
@shuson
shuson / getMyAWSRegion.js
Created November 16, 2022 09:09
based on your ip and return AWS region string, get aws region by ip, find aws region
const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')
const ipRangeCheck = require("ip-range-check")
const getMyAWSRegion = () => {
const ip = execSync('curl https://api.ipify.org -s').toString()
const awsIPFile = path.join(process.env.TMP, "ip-ranges.json")
execSync(`curl -o ${awsIPFile} https://ip-ranges.amazonaws.com/ip-ranges.json`).toString()
@shuson
shuson / read_in_chunk.py
Last active November 6, 2022 09:43
handle huge file reading in python
from functools import partial, wraps
from typing import TextIO, Callable
def chunked_file(fp, block_size):
for chunk in iter(partial(fp.read, block_size), ''):
yield chunk
def transformer(data):
//do transformation for input data
output = data
@shuson
shuson / s3download.js
Created October 31, 2022 05:40
S3 download file more than 2GB using nodejs
const fs = require("fs")
const s3 = require("aws-s3") // blabla
const totalSize = await getFileSize(file) // if this is more than 2147483638
logger.info("downloading huge file ... " + file)
const partSize = 547483640
const saveFilePath = "path_to_save.file"
const parts = Math.ceil(totalSize/partSize)
const writeStream = fs.createWriteStream(saveFilePath, {flags:'a'})
@shuson
shuson / gist:afaef984f6dc20076dee1364bc130d2a
Created August 25, 2021 10:45
152 secondary schools.csv
,school_name_s,type_s,postal_code_s,dsa_ip_types_b,address_s,is_has_psle_b,school_type_ss,co_cirricular_activities_ss,subjects_offered_ss,dsa_list_ss
0,Admiralty Secondary School,secondary_school,737916,False,31 Woodlands Crescent,True,['Government School'],"['Badminton', 'Netball', 'Rugby', 'Track and Field', 'Wushu', 'National Police Cadet Corps (NPCC)', 'National Cadet Corps (NCC) (Land)', 'National Civil Defence Cadet Corps (NCDCC)', 'Guzheng Ensemble', 'Modern Dance', 'English Drama', 'Concert Band', 'Art and Crafts', 'Robotics', 'Digital Media']","['Basic Chinese Language', 'Computer Applications', 'Design & Technology', 'Elements of Business Skills', 'English Language', 'Mathematics', 'Basic Malay Language', 'Science', 'Social Studies', 'Additional Mathematics', 'Art', 'Chinese Language', 'Design & Technology', 'English Language', 'Food & Nutrition', 'Food & Consumer Education', 'Geography', 'History', 'Literature in English', 'Mathematics', 'Malay Language', 'Nutrition and Food Science', 'Principles o
@shuson
shuson / cz-Dracula.xml
Last active February 16, 2021 03:22
Customized Dracula Theme for ConEmu
<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2020-04-28 17:19:40" build="191012">
<value name="ColorTable00" type="dword" data="00424321"/>
<value name="ColorTable01" type="dword" data="00eee9e8"/>
<value name="ColorTable02" type="dword" data="00f993bd"/>
<value name="ColorTable03" type="dword" data="00fde98b"/>
<value name="ColorTable04" type="dword" data="005555ff"/>
<value name="ColorTable05" type="dword" data="00c679ff"/>
@shuson
shuson / jgm.sh
Created October 1, 2019 14:19
家国梦收金币专用
#!/bin/bash
# 分辨率 1080x2340 小米9
echo "开始执行"
COUNTER=0
while [ $COUNTER -lt 100 ]
do
COUNTER=`expr $COUNTER + 1`
echo 第 $COUNTER 次执行
echo 开始
adb shell input swipe 260 320 260 1600 500
@shuson
shuson / httpd.conf
Created July 16, 2019 08:27
Frontend Project httpd rewrite rule
Listen 9090 # some port
<VirtualHost 172.0.0.1:9090>
DocumentRoot /var/www/project
#ServerName is fine to not specified
<Directory /var/www/project>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ /index.html [L]

确认下载好了 platform tools https://developer.android.com/studio/releases/platform-tools 插上手机, 开启debug mode 打开命令行, 跑一下

./adb -d shell sh /data/data/me.piebridge.brevent/brevent.sh
@shuson
shuson / how_about_e.md
Created March 3, 2018 08:31
自然底数e是怎么回事
  1. 假设你在银行存了1元钱(下图蓝圆),很不幸同时又发生了严重的通货膨胀,银行存款利率达到了逆天的100%!
  2. 银行发善心,每半年付利息,你可以把利息提前存入,利息生利息(红圆),1年存款余额=2.25元
  3. 假设银行人品爆发,一年365天,愿意天天付利息,这样利滚利的余额≈2.71456748202元
  4. 假设银行丧心病狂的每秒付利息,你也丧心病狂的每秒都再存入,1年共31536000秒,利滚利的余额≈2.7182817813元

1元存1年,在年利率100%下,无论怎么利滚利,其余额总有一个无法突破的天花板,这个天花板就是e

summary: 每个理想的存款,其余额都是e的倍数。