Skip to content

Instantly share code, notes, and snippets.

@bluefangs
bluefangs / random-ip-from-subnet.js
Last active December 17, 2018 17:41
random-ip-from-subnet ==> Produces a crudely random IP address from a given subnet.
function getIPFromSubnet(subnetRange) {
// subnetRange = "10.0.0.0/24"
const subnet = subnetRange.split('/')[0]; // 10.0.0.0
const mask = subnetRange.split('/')[1]; // 24
const ipArray = subnet.split('.'); //["10", "0", "0", "0"]
var ipInBinary = ""; // will contain the binary equivalent of the iP
sudo apt-get update <-- update
sudo apt-get install curl <-- install curl
apk add inotify-tools <--for the filewatcher methods
#### openssh-server ###
sudo apt-get install openssh-server <-- install ssh server
vi /etc/ssh/sshd_config
Port 22 <-- uncomment this
PermitRootLogin yes <-- add this if you want ssh access to root
save
@bluefangs
bluefangs / vs-task.json
Created March 12, 2018 17:47
simple sh task for vscode
{
"version": "2.0.0",
"tasks": [
{
"label": "Run shell script",
"type": "shell",
"command": "~/workspace/ezems/wow.sh",
// "windows": {
// "command": ".\\scripts\\test.bat"
// },
@bluefangs
bluefangs / Setup VM
Last active March 16, 2018 09:59
Bring-up instructions for alpine VM with docker
Install and run alpine linux. follow through with the setup procedure (setup-alpine)
Login as root user.
#### Install sudo ####
apk is the default package manager.
apk update <-- updates to the latest packages.
apk add sudo <-- installs sudo
#### Install docker ####
inotifywait -m /home/test -e create |
while read path action file; do
echo "The file '$file' appeared in directory '$path' via '$action'"
mv $path$file /home/test/archive/
# do something with the file
done
@bluefangs
bluefangs / docker-dump
Last active March 6, 2018 05:33
Docker for nodejs and mongo
-----------------------------------Install docker
$ sudo apt-get update
$ sudo apt-get install docker.io
-----------------------------------Add user to docker (to avoid using sudo)
https://askubuntu.com/a/477554/642604
$ sudo groupadd docker
$ sudo gpasswd -a $USER docker
$ newgrp docker
@bluefangs
bluefangs / ports.js
Created February 16, 2018 12:27
JS object array of well used TCP/UDP network ports - This can be used for UI selection
[{
"label": "Port: 1 (tcpmux)",
"value": 1
},
{
"label": "Port: 2 (compressnet)",
"value": 2
},
{
"label": "Port: 3 (compressnet)",
@bluefangs
bluefangs / countries.js
Created February 16, 2018 12:25
JS object array of country codes. Useful for any type of UI country selection
[
{
"alpha-2": "AD",
"value": "AD",
"alpha-3": "AND",
"num-3": 020,
"label": "Andorra"
},
{
"alpha-2": "AE",