Skip to content

Instantly share code, notes, and snippets.

View priyanshujain's full-sized avatar
🛠️
Always Building

pjay priyanshujain

🛠️
Always Building
View GitHub Profile
@priyanshujain
priyanshujain / generate-ssh-key.sh
Created July 27, 2018 18:55 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa
@priyanshujain
priyanshujain / nmonitor.sh
Created July 11, 2018 08:09 — forked from nitinbhojwani/nmonitor.sh
Monitor individual process metrics - nmonitor usage and shell script.
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "usage error: sh nmonitor.sh <pid> <time_to_monitor_in_seconds>";exit 1
fi
pid=$1
time=$2
#read -p "Please enter your process Id: " pid
@priyanshujain
priyanshujain / download.js
Last active July 28, 2018 17:17
Download data as file in browser
function download(data, filename, type) {
var file = new Blob([data], {type: type});
if (window.navigator.msSaveOrOpenBlob) // IE10+
window.navigator.msSaveOrOpenBlob(file, filename);
else { // Others
var a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
@priyanshujain
priyanshujain / pdftotext.py
Created June 18, 2018 12:59
Convert pdf to text using pdfminer
#!/usr/bin/env python
"""
A utility to convert the given resume into text file.
"""
import re
import logging
import configurations as regex
# for converting pdfs to text
@priyanshujain
priyanshujain / snippets.py
Last active May 17, 2018 14:03
Python snippets
# Match two strings
import difflib
string_a = 'python'
string_b = 'honbe'
matcher = difflib.SequenceMatcher(a=string_a, b=string_b)
match = matcher.find_longest_match(0, len(matcher.a), 0, len(matcher.b))
@priyanshujain
priyanshujain / xmlHttpReq.js
Created March 20, 2018 11:39
xmlHttpRequest example
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);
@priyanshujain
priyanshujain / chrome_ctrl_shortcuts.md
Last active February 10, 2018 15:41
My experiments with different shortcuts

List of chrome shortcuts with Ctrl + letter

  • C + e scroll down

  • C + w close tab

  • C + r reload page

  • C + t open new tab

@priyanshujain
priyanshujain / site1.conf
Last active January 31, 2018 04:12
Apache reverse proxy config for multiple sites as site1 and site2
<VirtualHost *:*>
ServerName site1.com
ServerAlias site1.com
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ErrorLog ${APACHE_LOG_DIR}/site1-web_error.log
@priyanshujain
priyanshujain / new-timezone.json
Last active December 26, 2017 06:04
List of timezones
[
{
"value": "Dateline Standard Time",
"abbr": "DST",
"offset": -12,
"isdst": false,
"text": "(UTC-12:00) International Date Line West",
"utc": [
"Etc/GMT+12"
]