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 / permute_list.erl
Created April 10, 2012 08:05
Permutation of List in Erlang
-export([permute/1, permute/2]).
permute(List) ->
permute(List, length(List)).
permute(List, Length) ->
Indices = [],
Permuted_List = [],
jumble(List, Permuted_List, Indices, Length).
baali / audio.html
Created May 4, 2012 17:20
chrome api for speech recognition
<!DOCTYPE html>
<html manifest="cache.appcache">
<head>Speech Recognition</head>
<input type="text" x-webkit-speech />
baali /
Created May 13, 2012 06:03
To check for duplicate files
if bool(fileName):
flag = 1
filePath = os.path.join(detach_dir, 'attachments', fileName)
if not os.path.isfile(filePath) :
print fileName
fp = open(filePath, 'wb')
tmpPath = os.path.join(detach_dir, 'attachments', fileName+'tmp')
baali / dump_file.cpp
Created August 24, 2012 07:58
DebugProtocol to print payload in human redable form.
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
baali /
Created December 15, 2011 07:12 — forked from lrvick/
Manually train an NLTK NaiveBayes Classifier
from nltk.probability import ELEProbDist, FreqDist
from nltk import NaiveBayesClassifier
from collections import defaultdict
train_samples = {
'I hate you and you are a bad person': 'neg',
'I love you and you are a good person': 'pos',
'I fail at everything and I want to kill people' : 'neg',
'I win at everything and I want to love people' : 'pos',
'sad are things are heppening. fml' : 'neg',
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",
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

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 /
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)
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