Skip to content

Instantly share code, notes, and snippets.

@mohan-mu
mohan-mu / uuid_v4.js
Created July 17, 2020 11:10 — forked from bentranter/uuid_v4.js
Spec Compliant UUIDv4 Generator using the Web Crypto API
// uuid returns an RFC 4122 compliant universally unique
// identifier using the crypto API
function uuid() {
// get sixteen unsigned 8 bit random values
var u = window
.crypto
.getRandomValues(new Uint8Array(16));
// set the version bit to v4
@mohan-mu
mohan-mu / 2019-https-localhost.md
Created April 20, 2020 13:01 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@mohan-mu
mohan-mu / osascript.rb
Created August 15, 2017 06:55 — forked from jpalumickas/osascript.rb
Osascript examples
# === Terminal.app === #
# Open new tab in terminal.
exec("osascript -e 'tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down' > /dev/null 2>&1 ")
# Open directory
exec("osascript -e 'tell application \"Terminal\" to do script \"cd directory\" in selected tab of the front window' > /dev/null 2>&1 ")
# Open directory in new tab (this is better)
exec("osascript -e 'tell application \"Terminal\"' -e 'tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down' -e 'do script with command \"cd directory && clear\" in selected tab of the front window' -e 'end tell' > /dev/null 2>&1")
# SYNTAX:
var pattern = new RegExp(pattern, attributes); # attributes: g (global); i (case-sensitive); m (multiline matches)
var pattern = /pattern/attributes; # same as above
# BRACKETS:
[...]: Any one character between the brackets.
[^...]: Any one character not between the brackets.
@mohan-mu
mohan-mu / cli.docker.sh
Created August 14, 2017 20:49 — forked from LeCoupa/cli.docker.sh
Docker Cheatsheet + Tips & Tricks
docker build -t friendlyname . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
docker exec -it [container-id] bash # Enter a running container
docker ps # See a list of all running containers
docker stop <hash> # Gracefully stop the specified container
docker ps -a # See a list of all containers, even the ones not running
docker kill <hash> # Force shutdown of the specified container
docker rm <hash> # Remove the specified container from this machine
docker rm $(docker ps -a -q) # Remove all containers from this machine
@mohan-mu
mohan-mu / bash-cheatsheet.sh
Created August 14, 2017 20:47 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@mohan-mu
mohan-mu / check4siteupdate.py
Created August 3, 2017 22:27 — forked from EronHennessey/check4siteupdate.py
A Python script that checks the last-modified date of a URL against the last-modified date of a previous look at it. If the last-modified date has changed, it emails the designated address, saying so. This could be used as a cron job to periodically check for updates of any page on the internet.
# check for an update on a web-page, and email the user
import httplib
import sys
import pickle
from datetime import datetime
import smtplib
from email.mime.text import MIMEText
import yaml
def email_user(cur_data, email_from, email_to):
@mohan-mu
mohan-mu / monitor-page.sh
Created August 1, 2017 11:34 — forked from djromero/monitor-page.sh
Send email and tweet when a web page changes in bash.
#!/bin/bash
# inspired in "Monitoring a web page for changes using bash"
# http://bhfsteve.blogspot.com.es/2013/03/monitoring-web-page-for-changes-using.html
# monitor.sh - Monitors a web page for changes
# sends an email notification and a tweet if the file changes
# requirements:
# - twitter from the command line [https://github.com/sferik/t]
# gem install t
# - sendemail