Skip to content

Instantly share code, notes, and snippets.

@skangmy
skangmy / gist:f96707edb909d1664a9f13cc94680949
Created February 21, 2023 04:49
Remove ansi color code
sed -i 's/\x1b\[[0-9;]*m//g' reporting.log
@skangmy
skangmy / gist:e1798b8ec06b458dddb4364bc07fbb4a
Created November 9, 2022 00:41
Commonly used linux command
// find file by name
// e.g. find . -iname 'SomeLog*'
find /path/to/file/ -iname filename
@skangmy
skangmy / gist:5d2fa3dbc51b7019a80b9d747f7d1b9c
Last active November 10, 2022 01:52
Frequently used Flux code
// return default value if v is null
// usage: coalesce(v: r.host, default: "missing")
coalesce = (v, default) => if exists v then v else default
// setting timezone
// needed when using aggregateWindow with period 1d and higher, or date truncate function
import "timezone"
option location = timezone.location(name: "Asia/Kuala_Lumpur")
@skangmy
skangmy / gist:6c585d12ad776db0cdbb4eb63bf672be
Created October 21, 2022 08:14
jquery http post function
function post(url, data) {
return new Promise((resolve, reject) => {
$.ajax({
url,
dataType: 'json',
type: 'post',
contentType: 'application/json',
data: JSON.stringify(data),
processData: false,
success: function (response, textStatus, jQxhr) {
@skangmy
skangmy / npm-install-all.sh
Last active March 3, 2022 07:04
Run npm install for all folders
ls -d */ | xargs -I {} bash -c "cd '{}' && npm install --only=prod"