Skip to content

Instantly share code, notes, and snippets.

View albertkurnia's full-sized avatar
🎯
Focusing

Albert Waruwu albertkurnia

🎯
Focusing
View GitHub Profile
@albertkurnia
albertkurnia / main.go
Created March 24, 2023 15:53
Golang program to send file to Google Drive & Dropbox
package main
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"os"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
@albertkurnia
albertkurnia / backup.sh
Created March 23, 2023 17:05
Bash script to backup log file everyday
#!/bin/bash
# Set the log file path and backup directory path
LOG_FILE="/var/log/example.log"
BACKUP_DIR="/var/log/backups"
# Create the backup directory if it doesn't exist
if [ ! -d "$BACKUP_DIR" ]; then
mkdir -p "$BACKUP_DIR"
fi
@albertkurnia
albertkurnia / backup.sh
Created March 23, 2023 17:00
Bash script to backup mysql database everyday
#!/bin/bash
# MySQL database credentials
USER="username"
PASSWORD="password"
DATABASE="database_name"
# Backup directory
BACKUP_DIR="/path"
package main
import (
"fmt"
"github.com/go-redis/redis"
)
var (
channel = "EXAMPLE"
package main
import (
"fmt"
"math/rand"
"time"
"github.com/go-redis/redis"
)
@albertkurnia
albertkurnia / .gitconfig
Last active March 4, 2020 09:01
My git configuration
[alias]
tree = log --graph --decorate --pretty=oneline --abbrev-commit
gam = "!git add -A && git commit -m "
gco = git checkout
gcb = git checkout -b
gpullm = git pull origin master
gpushm = git push -u origin master
gbl = git brach -l
gpusho = git push origin "$(git rev-parse --abbrev-ref HEAD)"
gpullo = git pull origin "$(git rev-parse --abbrev-ref HEAD)"
export GOPATH=$HOME/Workspace/Go
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
export ANDROID_HOME=/Users/albertwaruwu/Android
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
export PATH=${JAVA_HOME}/bin:$PATH
export PATH="$PATH:/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin"
code-insiders () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCodeInsiders" --args $* ;}
@albertkurnia
albertkurnia / map_practice.go
Created August 7, 2018 09:13
my answer for map practice in go playground
func WordCount(s string) map[string]int{
result := make(map[string]int)
split := strings.Fields(s)
for _, word := range split {
v, ok := result[word]
hitung:= v
if ok {
hitung+=1
result[word]= hitung
version: '3'
services:
db:
image: postgresql
ports:
- "25432:5432"
app:
image: sample-app
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER docker;
CREATE DATABASE docker;
GRANT ALL PRIVILEGES ON DATABASE docker TO docker;
EOSQL
PGPASSWORD=docker psql -U docker docker < /var/lib/postgresql/sample_db.sql