Skip to content

Instantly share code, notes, and snippets.

View dictcp's full-sized avatar

Dick Tang dictcp

View GitHub Profile
@dictcp
dictcp / eStatementToCsv.php
Last active January 11, 2022 06:23
Convert Hang Seng Bank eStatement To CSV file
<?php
// working command
// pdftotext -layout eStatementFile-2014-01-30.pdf - | grep -ozP 'TRANSACTION HISTORY(.|\n)*?\n\n\n' | php ~/a.php | fgrep '.' | grep -v "B/F BALANCE" | sed 's/,//g' | sed 's/;/,/g'
function trim_value(&$value)
{
$value=str_replace(',', '', $value);
$value = trim($value);
}
@dictcp
dictcp / nginx_sys_load.lua
Last active April 22, 2016 03:59
lua script to detect server overloading and skip process further request
--[[
a lua script to detect server overloading and skip process further request
inspired by the nginx extension: https://github.com/alibaba/nginx-http-sysguard
need nginx config like:
set $overloaded "0";
set_by_lua_file $dummy /etc/nginx/nginx_sys_load.lua;
if ($overloaded) {
return 503;
}
diff -Nur a/nginx-1.6.2/debian/control b/nginx-1.6.2/debian/control
--- a/nginx-1.6.2/debian/control 2016-02-10 21:51:05.000000000 +0000
+++ b/nginx-1.6.2/debian/control 2016-05-09 06:25:29.546456057 +0000
@@ -210,3 +210,53 @@
This package provides debugging symbols for nginx-extras, to assist in
debugging issues that you may find. It should not be required for normal
operation.
+
+Package: nginx-extrasplus
+Architecture: any

Keybase proof

I hereby claim:

  • I am dictcp on github.
  • I am dictcp (https://keybase.io/dictcp) on keybase.
  • I have a public key ASCPoev92kFTVy8EJX1A9O2CzPhc5oBqrPz-s1_dHqeOewo

To claim this, I am signing this object:

@dictcp
dictcp / 6_mar_2018_k8s_workshop_notes.md
Created March 7, 2018 14:17 — forked from foray1010/6_mar_2018_k8s_workshop_notes.md
6 Mar 2018 - Kubernetes (k8s) workshop notes

6 Mar 2018 - Kubernetes (k8s) workshop notes

workshop github guideline: https://github.com/aws-samples/aws-workshop-for-kubernetes

if you wanna follow the guideline, make sure you:

  1. setup cloud9, follow the instructions under the heading: Create AWS Cloud9 Environment
  2. setup Kubernetes multi master cluster, follow the instructions under the heading: Create a Kubernetes Cluster with kops and Kubernetes Cluster Context. Suggest to create a multi-master cluster as the examples will be easier to follow.

Concepts

  1. Pod
@dictcp
dictcp / result.txt
Last active May 24, 2018 17:17
Testing Service Type in k8s
# google is extenalname
root@test-665f47c685-rc7rt:/# host google
google.test-space.svc.cluster.local is an alias for www.google.com.
www.google.com has address 216.58.221.68
www.google.com has IPv6 address 2404:6800:4003:804::2004
google.test-space.svc.cluster.local has SRV record 10 100 0 www.google.com.
root@test-665f47c685-rc7rt:/# host -t A google
google.test-space.svc.cluster.local is an alias for www.google.com.
www.google.com has address 216.58.221.68
root@test-665f47c685-rc7rt:/# host -t CNAME google
http://www.oreilly.com/data/free/files/2014-data-science-salary-survey.pdf
http://www.oreilly.com/data/free/files/2015-data-science-salary-survey.pdf
http://www.oreilly.com/data/free/files/Data_Analytics_in_Sports.pdf
http://www.oreilly.com/data/free/files/advancing-procurement-analytics.pdf
http://www.oreilly.com/data/free/files/ai-and-medicine.pdf
http://www.oreilly.com/data/free/files/analyzing-data-in-the-internet-of-things.pdf
http://www.oreilly.com/data/free/files/analyzing-the-analyzers.pdf
http://www.oreilly.com/data/free/files/architecting-data-lakes.pdf
http://www.oreilly.com/data/free/files/being-a-data-skeptic.pdf
http://www.oreilly.com/data/free/files/big-data-analytics-emerging-architecture.pdf

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@dictcp
dictcp / EC2-Tag-Assets-Lambda.py
Last active October 14, 2022 07:51 — forked from mlapida/EC2-Tag-Assets-Lambda.py
A lambda function that will copy EC2 tags to all related Volumes and Network Interfaces. A full writeup can be found on my site http://mlapida.com/thoughts/tagging-and-snapshotting-with-lambda
import boto3
def lambda_handler(event, context):
is_test = context.function_name == 'test' # this value is injected by SAM local
instances = boto3.resource('ec2').instances.all()
copyable_tag_keys = ["Team", "Billing", "BillingTag", "Env", "Project"]
for instance in instances:
copyable_tags = [t for t in instance.tags