Skip to content

Instantly share code, notes, and snippets.

View baali's full-sized avatar
Working from home

baali baali

Working from home
View GitHub Profile
baali /
Created May 8, 2012 08:32
Python script to download all gmail attachments.
# Something in lines of
# Make sure you have IMAP enabled in your gmail settings.
# Right now it won't download same file name twice even if their contents are different.
import email
import getpass, imaplib
import os
import sys
detach_dir = '.'
baali /
Created August 30, 2012 10:03
TO convert YUV422 to YUV444 and eventually RGB format jpg file
import vision_definitions
import numpy
import time
import Image
camProxy = ALProxy("ALVideoDevice", NAO_IP, PORT)
t0 = time.time()
# block to capture image from NAO's camera with 640x480 resolution and YUV422 colorspace
client = camProxy.subscribe("client", vision_definitions.kVGA, vision_definitions.kYUV422ColorSpace, 5)
baali /
Created February 3, 2013 08:58
Decryption of Rot-n encoded message
# usage python encodedeMessage n
# python "Va gur ryringbef, gur rkgebireg ybbxf ng gur BGURE thl'f fubrf." 13
import sys
if __name__ == '__main__':
encodedMsg = sys.argv[1]
n = int(sys.argv[2])
# lets make everything lower case
encodedMsg = encodedMsg.lower()
decodedMsg = ''
baali /
Created March 27, 2020 06:22
Compare URLs and check if they are same
from urllib.parse import urlparse
def check_url_similarity(url_1, url_2):
'''Method to compare two URLs to identify if they are same or not.
Returns bool: True/False based on comparison'''
def check_path(path_1, path_2):
# handles cases where paths differ because of trailing /
if path_1 == path_2:
return True
if path_1 == path_2+'/' or \
path_1+'/' == path_2:
baali /
Created December 6, 2011 04:03
A Python script to break audio into chunks of smaller audios and using Google API to get Speech to Text.
A hack based on this While with smaller voice samples google speech to text works really good, as length increases quality decreases. So here using audiolab and numPy we are breaking audio sample, in smaller chunks, and removing blank/empty spaces from audio signal and then pushing them to google for processing.
It takes wav file format as input but can be changed to other formats too.
from scikits.audiolab import wavread, play, flacwrite
from numpy import average, array, hstack
import os
import sys
baali /
Created March 19, 2013 15:36
Google Speech to Text Api usage in Python
# based on
# needs pyaudio package
# Linux based, sox commands to convert from way to flac format.
import pyaudio
import wave
import subprocess, shlex
CHUNK = 1024
FORMAT = pyaudio.paInt16
baali /
Created September 17, 2012 02:41 — forked from anonymous/
def swear(self, mess, args):
"swears randomley from a list of high level swear words"
swears = ["neech","kameen","kuttey", "howley", "saaley", "monkey", " kaachina vennela to tea pettukune mohavu nuvvu nu ","thitlu adukkunne mohamu nuvvoonu ", " currentu teegaki uyyala eskune ooge mohavu nuvvu" , "donkey", "vudathalu patte mokam", "chapathi mokam", "washbasin lo chepalu patte mokam", "gaali vaanalo visnakarrlu ammukune mokam", "Chunchu mokam", "ghootley", "jaffa", "tussha", "daffa", "jumper mein bumper", "panther pagdi" ,"lapaki paapa" ]
from random import choice
self.message_queue.append(choice(swears)+ " " + choice(swears) + " " + choice(swears) + " "+ args)

Keybase proof

I hereby claim:

  • I am baali on github.
  • I am baali ( on keybase.
  • I have a public key whose fingerprint is F891 136A 3FFB 0C7A B11E CDB5 5DB9 B0A6 8529 E773

To claim this, I am signing this object:

baali /
Last active June 6, 2016 19:49
Python script to plot amplitude of noise levels
import sys
import audioop
import pyaudio
except ImportError:
sys.exit('You need to install pyaudio to installed to run this demo.')
line = None
baali /
Last active May 28, 2016 05:16
MajorClust algorithm implementation using sklearn based on SO conversation about text clustering using python(
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import linear_kernel
import numpy as np
from itertools import combinations
from random import shuffle
def majorclust_sklearn():
texts = [
"foo blub baz",
"foo bar baz",