Skip to content

Instantly share code, notes, and snippets.

@asjain
asjain / read_file.html
Last active February 21, 2020 21:16
read file in html
<!DOCTYPE html>
<html>
<style>
table, td {
border: 1px solid black;
width:1000px;
text-align: center;
}
</style>
<body>
@asjain
asjain / basic.html
Last active February 21, 2020 17:42
first html demo
<!DOCTYPE html>
<html>
<body>
<h2 text-align="center">My team's landing page</h2>
<h3>Select some links from below</h3>
<h4>This is a header</h4>
<a href="https://imgur.com/r/cats">Show me some cats</a>
@asjain
asjain / gui1.py
Created February 10, 2020 23:57
python gui: just drop down menu
import sys
from Tkinter import * ## Python 2.x
#from tkinter import * ## Python 3.x
class window:
def __init__(self,master):
self.master = master
self.master.title("Elaborate gui to send an email v0.5")
self.master.option_add("*Font", "DEC\ Terminal")
self.day_frame = Frame(self.master, width = 800, bd = 1, relief = SUNKEN)
@asjain
asjain / read_json.js
Last active February 10, 2020 21:30
read json file in js
var printer = document.getElementById("demo")
var HttpClient = function() {
this.get = function(aUrl, aCallback) {
var anHttpRequest = new XMLHttpRequest();
anHttpRequest.onreadystatechange = function() {
if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200)
aCallback(anHttpRequest.responseText);
}
@asjain
asjain / my.py
Last active February 7, 2020 21:29
argparse example
import argparse
import sys
import os
def msg():
use = "my.py -h prints this help menu\n"
use += "my.py -p <PROJECT> -i <INPUT_CFG_FILE>"
return use
def parse_args():
parser = argparse.ArgumentParser(description='This script does something', usage=msg())
@asjain
asjain / sqlite
Created January 20, 2020 00:50
basic sqlite3 commands
sqlite3 my_tiny.db
SQLite version 3.6.13
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
# create a table
sqlite> create table my_tiny_table (
ID INT PRIMARY KEY NOT NULL,
PROJECT TEXT NOT NULL,
USER TEXT NOT NULL);
# show all tables
@asjain
asjain / vim commands
Last active January 19, 2020 22:33
vim commands
:set ft? #find current syntax/file type
:+,$d #delete all lines after current line
:g/^$/d #delete blank lines
:g/string/d #delete lines with "string"
:g/string/.,+10d #delete 10 lines after match
:g/string/+d3 #delete 3 lines below match
:g/string/d+3 #delete current + 2 lines below
:g/string/d-3 #delete current + 2 lines above
:10,100d #delete lines 10 to 100, included
:%!column -t #makes nice columns, very useful for logs
@asjain
asjain / unix_cmds.sh
Last active February 20, 2020 19:44
unix useful commands
sed -n '32,39p' file1 > file2 #copies lines betn 32-39 into file2
sed -i 's/original/new/g' file #search and replace 'orignal' with 'new'
sed -i '/^$/d' *.txt #remove empty lines in place in .txt files
find . -type f -exec sort -o {} {} \; #sort all the files in place
find . -name '*.txt' -exec sort -o {} {} \; #will sort only .txt files
ls -1 #print list in 1 column
zgrep #grep in .gz file
grep -v #inverted grep
grep -s #suppress no file found error
grep -B 5 #print 5 lines before match
@asjain
asjain / aliases
Created January 19, 2020 22:08
unix aliases file sample
alias home 'cd /my/disk/path/'
alias myname 'set prompt = "\n%{%}%m:%~>\n>>"'
alias c 'clear'
alias g gvim
alias h 'history'
alias j 'jobs -l'
alias hg 'history|grep '
alias psg 'ps -ef | grep'
alias .. 'cd ..'
alias cd.. 'cd ..'
@asjain
asjain / toast.ps1
Created November 2, 2018 00:56
toast
$myName = "Abhishek"
$myHome = "&destinations=PutYourDestinationHere"
$myWork = "&origins=PutYourOriginHere"
$mapsKey = "&key=GetAKeyFromGoogleMapsAPI"
$departTime = "&departure_time=now"
$mapApiUrl = "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial"
$finalUrl = "$mapApiUrl$myWork$myHome$departTime$mapsKey"
$shortUrl = "ShortenedURLofRoute" # this is shortened URL of google maps route
#$final_url