Skip to content

Instantly share code, notes, and snippets.

View uudashr's full-sized avatar

Nuruddin Ashr uudashr

View GitHub Profile
@uudashr
uudashr / ask.sh
Last active March 1, 2017 04:48
Prompt / ask something in shell script
#!/bin/sh
read -p "Install directory [/root]: " installDir; installDir=${installDir:-/root}; echo $installDir
@uudashr
uudashr / main.go
Last active April 20, 2025 00:33
Listening for signal termination in Golang (AKA shutdown hook)
package main
import (
"fmt"
"log"
"os"
"os/signal"
"syscall"
)
@uudashr
uudashr / day_bounds.js
Created May 21, 2014 08:14
Get the bounds of a day
function dayBounds(date) {
var t1 = new Date(date.getTime());
t1.setHours(0, 0, 0, 0);
var t2 = new Date(date.getTime());
t2.setHours(23, 59, 59, 999);
return [t1, t2];
}
@uudashr
uudashr / week_bounds.js
Created May 18, 2014 11:55
Get week bounds from a date
/*
* Usage:
* new Date().weekBounds()
*
* or
*
* weekBounds(new Date());
*/
function weekBounds(date) {
@uudashr
uudashr / 0_reuse_code.js
Created May 18, 2014 11:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console