Skip to content

Instantly share code, notes, and snippets.

View imambungo's full-sized avatar

M Imam Pratama imambungo

View GitHub Profile
@imambungo
imambungo / battery_alert.sh
Last active May 22, 2022 08:38
ultraman low battery
#!/bin/bash
low_battery_percent=20
low_remaining_minute=5 # max is 60
low_battery_sound_file="~/bin/ultramanCTSE.mp3"
full_battery_sound_file="~/bin/full_battery.wav"
max_sound_length_in_second=10 # max is 60
# Dependencies & Troubleshooting: https://superuser.com/a/308441/943615
@imambungo
imambungo / gist:54481ed60fbf11e599fc1ab37677eee2
Last active March 24, 2020 17:23 — forked from junegunn/gist:f4fca918e937e6bf5bad
Browsing git commit history with fzf
# https://gist.github.com/junegunn/f4fca918e937e6bf5bad#gistcomment-2731105
# my git log
mgl()
{
local the_git_log = 'git log --graph --pretty=format:"%C(bold blue)%s%C(auto)%d%n%C(yellow)%h%Creset %an, %C(magenta)%ar%Creset at %C(cyan)%ad%n%b" --date=format:"%H:%M" --author-date-order --all'
ggloga --color=always | \
fzf --ansi --no-sort --reverse --tiebreak=index --preview \
'source ~/.alias; f() { set -- $(echo -- "$@" | grep -o "[a-f0-9]\{7\}"); [ $# -eq 0 ] || git show --color=always $1 ; }; f \
"$(the_git_log | head -$(({n} + 2)) | tail -2)"' \
--bind 'ctrl-j:preview-down,ctrl-k:preview-up,alt-j:preview-page-down,alt-k:preview-page-up,ctrl-m:execute: \
@imambungo
imambungo / tts
Last active September 22, 2019 01:50
Use Google Translate's Text to Speech without leaving the terminal.
#!/usr/bin/env bash
# Sample usage : tts "your text here"
# or : tts your text here (if there are no symbol)
tts() {
input="$@"
# https://stackoverflow.com/a/56321886/9157799
query=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$input'))")
@imambungo
imambungo / github
Last active March 12, 2021 07:13 — forked from igrigorik/github.bash
Open GitHub URL for current directory/repo...
#!/usr/bin/env bash
# usage: gh [file]
gh() {
repoURL=$(git config remote.origin.url | sed "s~git@\(.*\):\(.*\)~https://\1/\2~" | sed "s~\(.*\).git\$~\1~")
branch=$(git branch | grep \* | cut -d ' ' -f2)
relativePath=$(git rev-parse --show-prefix)
google-chrome "$repoURL/tree/$branch/$relativePath$1"
}
@imambungo
imambungo / Main.java
Last active October 14, 2019 11:29
Calculating the nth Root in Java https://github.com/eugenp/tutorials/issues/6806
import java.lang.Math;
public class Main
{
public static void main(String[] args)
{
nthRootCalculatorTest(10000, 8);
}
public static Double calculateNthRootUsingMathLog(Double base, Double n)