Skip to content

Instantly share code, notes, and snippets.

View pramttl's full-sized avatar

Pranjal Mittal pramttl

View GitHub Profile
@pramttl
pramttl / iterm2.zsh
Created May 7, 2021 06:46 — forked from wadey/iterm2.zsh
Change iTerm2 tab color when using SSH
# Usage:
# source iterm2.zsh
# iTerm2 tab color commands
# https://iterm2.com/documentation-escape-codes.html
if [[ -n "$ITERM_SESSION_ID" ]]; then
tab-color() {
echo -ne "\033]6;1;bg;red;brightness;$1\a"
echo -ne "\033]6;1;bg;green;brightness;$2\a"
@pramttl
pramttl / latency.txt
Created July 24, 2017 08:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@pramttl
pramttl / numeric_integration.cpp
Last active January 12, 2017 21:32
numeric_integration.cpp
//
// Numerical Integration
//
// NUMS = Number of divisions
// NUMT = Number of threads
// These parameters should be passed in from an external driver program
// Performance = NUMS*NUMS/t
// t = Runtime of program in microseconds
@pramttl
pramttl / speak_osu.py
Created February 21, 2015 00:46
Mac voices say Oregon State University
import os
voices = ['Agnes', 'Kathy', 'Princess', 'Vicki', 'Victoria',
'Alex', 'Bruce', 'Fred', 'Junior', 'Ralph', 'Albert',
'Bad News', 'Bahh', 'Bells', 'Boing', 'Bubbles', 'Cellos', 'Deranged',
'Good News', 'Hysterical', 'Pipe Organ', 'Trinoids', 'Whisper', 'Zarvox']
for voice in voices:
os.system('say -v %s "Oregon State University" '%(voice,))
#coding: utf-8
from cStringIO import StringIO
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email import Charset
from email.generator import Generator
import smtplib
# Example address data
@pramttl
pramttl / sendgrid.py
Created October 17, 2011 19:18 — forked from vivekn/sendgrid.py
Sendgrid example
def sendgrid(from_email, to_email, subject, message):
msg = MIMEText(message)
msg['Subject'] = subject
msg['From'] = from_email
msg['To'] = to_email
# Login credentials to sendgrid
username = '**********'
password = "**********"