Skip to content

Instantly share code, notes, and snippets.

View aladhims's full-sized avatar
:octocat:
Trying

Alfian Dhimas aladhims

:octocat:
Trying
View GitHub Profile
@aladhims
aladhims / graceful_shutdown.go
Last active March 11, 2023 21:53
Graceful Shutdown Go App
package main
// operation is a clean up function on shutting down
type operation func(ctx context.Context) error
// gracefulShutdown waits for termination syscalls and doing clean up operations after received it
func gracefulShutdown(ctx context.Context, timeout time.Duration, ops map[string]operation) <-chan struct{} {
wait := make(chan struct{})
go func() {
s := make(chan os.Signal, 1)
@aladhims
aladhims / hammerspoon.lua
Created July 25, 2020 11:47
My Personal Hammerspoon Configuration
local hyper = { "cmd", "alt", "ctrl", "shift" }
hs.hotkey.bind(hyper, "0", function()
hs.reload()
end)
hs.notify.new({title="Hammerspoon", informativeText="Config loaded"}):send()
hs.hotkey.bind(hyper, "l", function()
hs.caffeinate.lockScreen()