Skip to content

Instantly share code, notes, and snippets.

🤓

Fazle Arefin fazlearefin

🤓
View GitHub Profile
@fazlearefin
fazlearefin / docker-run-centos.sh
Created May 19, 2020
Script to create a docker centos with a bash shell and then destroy it afterwards
View docker-run-centos.sh
#!/bin/bash
DOCKER_COMPOSE_FILE='/tmp/docker-compose-centos.yml'
cat << 'EOF' > $DOCKER_COMPOSE_FILE
---
version: "3"
services:
@fazlearefin
fazlearefin / docker-run-ubuntu.sh
Created May 19, 2020
Script to create a docker ubuntu with a bash shell and then destroy it afterwards
View docker-run-ubuntu.sh
#!/bin/bash
DOCKER_COMPOSE_FILE='/tmp/docker-compose-ubuntu.yml'
cat << 'EOF' > $DOCKER_COMPOSE_FILE
---
version: "3"
services:
@fazlearefin
fazlearefin / update_vagrant_boxes
Last active May 17, 2020
Update all your vagrant boxes | bash/zsh function
View update_vagrant_boxes
function update_vagrant_boxes {
OLDIFS=$IFS
export IFS=$'\n'
# Find all boxes which have updates
AVAILABLE_UPDATES=$(vagrant box outdated --global | grep outdated | tr -d "*'" | cut -d ' ' -f 2 2>/dev/null)
if [[ ${#AVAILABLE_UPDATES[@]} -ne 0 ]]; then
while read box; do
@fazlearefin
fazlearefin / update_docker_images
Last active May 17, 2020
Update all your docker images | bash/zsh function
View update_docker_images
function update_docker_images {
# update docker images
docker images --format "{{.Repository}}:{{.Tag}}" | grep -v "<none>" | sort -u | xargs -L1 docker pull
# cleanup images containing no tags; usually the ones which get updated; USE WITH CAUTION
if nonetags=$(docker images | grep "<none>"); then awk '{ print $3 }' <<< $nonetags | xargs -L1 docker rmi -f; fi
}
@fazlearefin
fazlearefin / vagrant-multi-node
Created Jun 9, 2019
Vagrant template for multi node setup
View vagrant-multi-node
domain = 'example.com'
nodes = [
{ hostname: 'lb01', ip: '192.168.250.10', box: 'ubuntu/bionic64', cpus: '1', ram: '256' },
{ hostname: 'node01', ip: '192.168.250.21', box: 'ubuntu/bionic64', cpus: '1', ram: '256' },
{ hostname: 'node02', ip: '192.168.250.22', box: 'ubuntu/bionic64', cpus: '1', ram: '256' },
{ hostname: 'node03', ip: '192.168.250.23', box: 'ubuntu/bionic64', cpus: '1', ram: '256' },
]
Vagrant.configure('2') do |config|
@fazlearefin
fazlearefin / macOSHighSierra_Bootable.sh
Created May 20, 2019 — forked from Vincent-St/macOSHighSierra_Bootable.sh
Create a Bootable macOSHighSierra.iso for installing macOS High Sierra in Virtualbox or VMware with macOS High Sierra.app
View macOSHighSierra_Bootable.sh
# Create a Bootable macOSHighSierra.iso for installing macOS High Sierra in Virtualbox or VMware with macOS High Sierra.app
# Create a "virtual USB flash drive"/disk image:
hdiutil create -o /tmp/HighSierra -size 8G -layout SPUD -fs HFS+J -type SPARSE
# Mount it:
hdiutil attach /tmp/HighSierra.sparseimage -noverify -mountpoint /Volumes/install_build
# Write the installer files into this new disk image:
@fazlearefin
fazlearefin / ozlotto_generate.cpp
Created Jan 27, 2019
ozlotto | Generate all combinations
View ozlotto_generate.cpp
#include <stdio.h>
/* Prints out a combination like {1, 2} */
void printc(int comb[], int k) {
printf("{");
int i;
for (i = 0; i < k; ++i)
printf("%d, ", comb[i] + 1);
printf("\b\b}\n");
}
@fazlearefin
fazlearefin / download-org-repos.sh
Created Sep 28, 2018
Download all public git repos of an organization
View download-org-repos.sh
#!/usr/bin/env bash
if [[ $# -ne 1 ]]; then
echo "Missing org name" >&2
echo "Usage: $0 <org>" >&2
exit 1
fi
ORG_NAME=$1
BASE_URL="https://api.github.com/orgs/$1/repos"
@fazlearefin
fazlearefin / gist:fd6d6643c818b25b8a5909600ebb5fed
Last active May 22, 2017
How to determine Linux kernel architecture?
View gist:fd6d6643c818b25b8a5909600ebb5fed
#!/bin/bash
getconf LONG_BIT # will output either 32 or 64
@fazlearefin
fazlearefin / ozlotto_gen.R
Created Apr 19, 2017
Oz Lotto | Generate all combination of main numbers using R
View ozlotto_gen.R
# launch R console
# create a vector of all possible numbers or just your lucky numbers
all_nums = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45)
# increase value of max.print so that output is not omitted
# 45,379,620 combinations, so set the max.print to some high value
options(max.print=999999999)
# main numbers are 7 numbers long
You can’t perform that action at this time.