Skip to content

Instantly share code, notes, and snippets.

View ariefrahmansyah's full-sized avatar
🇵🇸

Arief Rahmansyah ariefrahmansyah

🇵🇸
View GitHub Profile
kubectl run -i --rm --tty --image=postgres:12.6 --restart=Never --env POSTGRES_PASSWORD=“${PASSWORD}” --env PGPASSWORD=“${PASSWORD}” psql-shell -- psql -h "${HOST}" -d "${DATABASE}" -U "${USER}"
docker rm -f $(docker ps -aq) && docker rmi -f $(docker image ls -q) && docker volume rm $(docker volume ls -q) && docker system prune -f
@ariefrahmansyah
ariefrahmansyah / BatteryStatusNotification.scpt
Last active June 28, 2022 09:37
Mac's Battery Status Notification
repeat
set chargeState to do shell script "pmset -g batt | awk '{printf \"%s %s\\n\", $4,$5;exit}'"
set percentLeft to do shell script "pmset -g batt | egrep -ow '([0-9]{1,3})[%]' | egrep -ow '[0-9]{1,3}'"
considering numeric strings
if chargeState contains "Battery Power" and percentLeft ≤ 20 then
display notification "Time to plug me in 🔌" with title "Battery Charge Boundary" sound name "Ping"
#else if chargeState contains "AC Power" and percentLeft ≥ 80 then
# display notification "Time to unplug me 🔋" with title "Battery Charge Boundary" sound name "Ping"
end if
@ariefrahmansyah
ariefrahmansyah / BatteryStatusNotification.scpt
Created March 29, 2022 02:31 — forked from brandon1024/BatteryStatusNotification.scpt
Battery Percentage Boundary Notification Background Script for macOS
repeat
set chargeState to do shell script "pmset -g batt | awk '{printf \"%s %s\\n\", $4,$5;exit}'"
set percentLeft to do shell script "pmset -g batt | egrep -ow '([0-9]{1,3})[%]' | egrep -ow '[0-9]{1,3}'"
considering numeric strings
if chargeState contains "Battery Power" and percentLeft ≤ 40 then
display notification "Time to plug me in :)" with title "Battery Charge Boundary"
else if chargeState contains "AC Power" and percentLeft ≥ 80 then
display notification "Time to unplug me :)" with title "Battery Charge Boundary"
end if
end considering
@ariefrahmansyah
ariefrahmansyah / transformers-nlp.md
Last active June 4, 2021 04:02
Transformers in NLP

What is Transformers in NLP?

Concepts

Attention

  1. Encoder-Decoder Attention: Attention between the input sequence and the output sequence.
  2. Self attention in the input sequence: Attends to all the words in the input sequence.
  3. Self attention in the output sequence: One thing we should be wary of here is that the scope of self attention is limited to the words that occur before a given word. This prevents any information leaks during the training of the model. This is done by masking the words that occur after it for each step. So for step 1, only the first word of the output sequence is NOT masked, for step 2, the first two words are NOT masked and so on.
@ariefrahmansyah
ariefrahmansyah / protoc.go
Created March 22, 2020 22:50 — forked from mxk/protoc.go
TensorFlow Serving gRPC interface generator for Go
//+build ignore
// TensorFlow Serving gRPC interface generator.
//
// This script works around a bunch of issues (as of 2019-08-25) between Go's
// protobuf compiler plugin, Go modules, and definitions of TensorFlow and
// TensorFlow Serving proto files. It assumes that protoc and protoc-gen-go are
// on your PATH.
//
// git clone -b r1.15 https://github.com/tensorflow/tensorflow.git
history | \
awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | \
grep -v "./" | \
column -c3 -s " " -t | \
sort -nr | nl | head -n 10
@ariefrahmansyah
ariefrahmansyah / compare_glide-novendor_go-list.sh
Created October 20, 2018 06:10
Compare glide novendor and go list
#!/bin/bash
# To ensure that migrating from glide novendor to go list is giving us equal result.
# https://github.com/jaegertracing/jaeger/pull/1127
GLIDE_PKGS=$(glide novendor | sort | grep -v -e ./thrift-gen/... -e ./swagger-gen/... -e ./examples/... -e ./scripts/...)
GO_PKGS=$(go list ./... | grep -v -e examples -e scripts -e swagger-gen -e thrift-gen)
GOCACHE="/Users/ariefrahmansyah/Library/Caches/go-build"
clear_cache() {
@ariefrahmansyah
ariefrahmansyah / go_makefile
Last active September 9, 2018 18:12
Go's Simple Makefile
GO=go
GOBUILD=${GO} build
GOINSTALL=${GO} install
GOTEST=${GO} test
GODEP=dep
export NOW=$(shell date +'%FT%T%z')
ROOT_PATH="github.com/ariefrahmansyah"
APP_NAME="[MY-AWESOME-APP]"
@ariefrahmansyah
ariefrahmansyah / docker_non_root.md
Last active February 11, 2018 08:54
Manage Docker as a non-root user

Manage Docker as a non-root user

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user.

If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.


Add the docker group if it doesn't already exist: sudo groupadd docker