Skip to content

Instantly share code, notes, and snippets.

View SahilC's full-sized avatar

Sahil Chelaramani SahilC

View GitHub Profile
@SahilC
SahilC / intro.py
Last active November 2, 2022 13:55
Due to recent events, I've decided to make this script to help you get to know me better. Please run the script to find out more.
'''
Due to recent events, I've made this script to help you get to know me better.
Please run the script to find out more.
'''
import base64
# pip install pillow
# pip install requests
from PIL import Image, ImageDraw, ImageFont
import numpy as np
import requests
@SahilC
SahilC / octopong.py
Created October 24, 2022 06:55
Use `pygame` to render custom pong env. Goal is to have a controllable env to train RL agents.
#!/usr/bin/env python
# coding: utf-8
import pygame
import time
import random
from joblib import load
pygame.init()
# Run on either ubuntu or Powershell, don't use wsl2 as it's not supported
@SahilC
SahilC / hbd.py
Created October 23, 2022 19:18
Using `pyaudio` to sound the happy birthday tune.
#!/usr/bin/env python3
# pip install pyaudio
import pyaudio
import struct
import math
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
@SahilC
SahilC / vimrc
Created January 4, 2018 08:11
My vimrc file tweaked heavily for productivity in python.
set nocompatible " required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@SahilC
SahilC / Visualize.ipynb
Last active March 8, 2017 08:48
Gist to itorch notebook to help visualize weights for CNN.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SahilC
SahilC / specialScript.py
Last active March 30, 2016 14:15
:) :) :)
import matplotlib.pyplot as mpplt
import matplotlib.gridspec as gridspec
import numpy
figure = mpplt.figure(figsize=(11, 10))
gs = gridspec.GridSpec(3, 12)
plt = figure.add_subplot(gs[0, :])
plt.hlines(3, -10, 10, color='red')
plt.hlines(-3, -10, 10, color='red')
@SahilC
SahilC / Define.sh
Created December 9, 2014 13:44
Use this script to find meanings of words from bash shell. For convenience, make this script executable and add alias to file with the command `alias define='path-to-define.sh-file'`
#!/bin/bash
wget -q -O - "http://www.macmillandictionary.com/dictionary/british/$1" | grep -P -o "<span class=\"DEFINITION\">(.*?)</span>" | grep -Po '(?<=href=")[^"]*' | grep -Po '=.*?$' | cut -d = -f 2 | awk '{printf "%s ",$1}'
@SahilC
SahilC / quotes.sh
Created December 9, 2014 10:24
A bash script to give you a random quote everytime you open your terminal. Add the following lines to your bashrc.
# font color : green
color='\e[0;32m'
# font color : white
NC='\e[0m'
getquote(){
num_online_quotes=9999
rand_online=$[ ( $RANDOM % $num_online_quotes ) + 1 ]
quote=$(wget -q -O - "http://www.quotationspage.com/quote/$rand_online.html" |
@SahilC
SahilC / gist:af0206645e069fded7db
Created August 22, 2014 12:27
Find all IPs connected to a network, assuming that your IP range is 192.168.1.x
#!/bin/bash
for ip in 192.168.1.{1..254}; do
ping -c 1 -W 1 $ip | grep "64 bytes" &
done
@SahilC
SahilC / Primes.py
Created September 10, 2013 13:22
Strangely awesome way to find prime numbers
def prime(n):
for i in range(3,n):
if 2**(i-1)%i==1:
print i