Skip to content

Instantly share code, notes, and snippets.

View ShiraazMoollatjie's full-sized avatar

Shiraaz Moollatjie ShiraazMoollatjie

View GitHub Profile
@ShiraazMoollatjie
ShiraazMoollatjie / random_date_range.go
Created August 3, 2020 18:37
go: generate a random date based on a range
n := time.Now()
rand.Seed(n.UnixNano())
// Keep track of the minimum and maximum age
e := n.AddDate(-minAge, 0, 0).Unix()
s := n.AddDate(-maxAge, 0, 0).Unix()
// Take the delta of the date and print it out, return it, whatever
sec := rand.Int63n(e-s) + s
fmt.Sprintf("%v", time.Unix(sec, 0))
@ShiraazMoollatjie
ShiraazMoollatjie / random_range.go
Last active August 3, 2020 18:36
go: generate a random number within a time range
// Generate a random number between a range.
rand.Seed(time.Now().UnixNano())
rand.Intn(max - min) + min
// Generate a random number with a minimum value
rand.Seed(time.Now().UnixNano())
rand.Int() + min
@ShiraazMoollatjie
ShiraazMoollatjie / push-all.sh
Created February 16, 2020 18:58
Push all git repos to master (with user defined directories)
#!/bin/bash -e
# Edit this list
REPOS=(
/Users/me/repo1
/Users/me/repo2
/Users/me/repo3
)
for i in “${REPOS[@]}”
do
### Keybase proof
I hereby claim:
* I am shiraazmoollatjie on github.
* I am shiraazl (https://keybase.io/shiraazl) on keybase.
* I have a public key ASCSVWnO9FlsviyaWIUd2W8yjqHcku8rCN8K8z4tad-b-wo
To claim this, I am signing this object:
@ShiraazMoollatjie
ShiraazMoollatjie / null_resource_example.tf
Created June 13, 2018 08:33
How to use null resources on many instances
resource "null_resource" "echo" {
count = "${var.number_of_instances}"
triggers {
ec2_servers = "${join(",", module.base_module.ip_addresses)}"
}
connection {
host = "${element(module.base_module.ip_addresses, count.index)}"
}
@ShiraazMoollatjie
ShiraazMoollatjie / add_vboxsf_to_user.sh
Last active June 1, 2018 07:55
[Linux Guest Only] When using automounting in Virtualbox, and you cannot access the shared folder because you do not have access. You need to add the vboxsf group for the user
sudo usermod -aG vboxsf <your username>
@ShiraazMoollatjie
ShiraazMoollatjie / registerMachineAndMountIso.ps1
Last active May 28, 2018 08:26
Create a virtualbox VM in powershell by giving it an identifier and an ISO file
# Assumes that you have virtualbox installed
# Save this as a file and run it as
# powershell -f registerMachineAndMountIso.ps1
param(
[string]$VM_NAME = "Budgie_64Bit",
[string]$VM_ISO = "D:\linux-isos\ubuntu-budgie-18.04-desktop-amd64.iso"
)
# Register VM so that you can see it on VirtualBox Manager