Skip to content

Instantly share code, notes, and snippets.

@mohan-mu
mohan-mu / urlParser.js
Last active August 16, 2017 07:46
Sample URL Parser
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@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
@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 / 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 / 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
# 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 / 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")
@mohan-mu
mohan-mu / bash_aliases.sh
Last active September 23, 2017 12:27
bash aliases
#opens the files containing the computer network related stuff
alias cn='nautilus /media/mohan/Stuffs/Learning/CN && nautilus /media/mohan/Stuffs/Learning/Videos && nautilus /media/mohan/Recent/3rd\ SEM\ RVCE\ Study\ stuff/'
#for hibernating
alias hib_custom='gksudo pm-hibernate'
#set text to clipboard
alias setclip="xclip -selection c"
#get contents of clipboard
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OracleClient;
@mohan-mu
mohan-mu / Jack's
Last active December 1, 2017 07:10
Dust
sudo i -t nat -A POSTROUTING -o th -j MASQUERADE
S I -t nat -A PREROUTING -i th -j DNAT --to-destination thip