Skip to content

Instantly share code, notes, and snippets.

View sudevschiz's full-sized avatar
🎯
Focusing

Sudev sudevschiz

🎯
Focusing
  • Soon enough!
  • Tokyo, Japan
View GitHub Profile
#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import unicodecsv as csv
#Twitter API credentials
consumer_key = "ADD KEY BEFORE USE"
consumer_secret = "ADD SECRET BEFORE USE"
access_key = "ADD KEY BEFORE USE"
library(streamR)
library(ROAuth)
setwd("~/tweet_miner_boy/")
# The following four lines assign the right values to the variables that
# are needed for the API call.
requestURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- "https://api.twitter.com/oauth/authorize"
@sudevschiz
sudevschiz / speech_to_text setup.md
Last active April 1, 2017 11:11
Setting up Google Cloud Speech API in Google Compute Engine

Create a new VM instance in Google Cloud Console Note that gcloud will already be installed in the system

gcloud init

Choose the service account of the VM Choose project

@sudevschiz
sudevschiz / sr_setup.sh
Created March 29, 2017 01:48
Commands to setup Python SpeechRecognition library and get it working
sudo apt-get install python3-dev
virtualenv -p python3 venv
source venv/bin/activate
pip install SpeechRecognition
sudo apt-get install -qq python python-dev python-pip build-essential swig git libpulse-dev
pip install --upgrade pocketsphinx
git clone https://github.com/Uberi/speech_recognition.git
cd speech_recognition/
ls
@sudevschiz
sudevschiz / data_science_setup
Created November 25, 2016 07:51
Data Science tool box setup in a new debian based machine
#install r-base
sudo apt-get -y install r-base
#install rstudio server 64-bit
sudo apt-get -y install gdebi-core
wget https://download2.rstudio.org/rstudio-server-1.0.44-amd64.deb
sudo gdebi rstudio-server*
@sudevschiz
sudevschiz / word_counter.py
Last active February 3, 2016 06:33
Count the frequency of words in a list and print the Word - Frequency table
from collections import defaultdict
#words = "apple banana apple strawberry banana lemon"
file = open("input.txt")
words = file.read()
words = words.split()
result = defaultdict(int)
for word in words:
result[word] += 1
@sudevschiz
sudevschiz / rosalind.py
Created February 2, 2016 18:17
Calculating Protein Mass with File handling
#!/usr/bin/env python
# coding=utf-8
# Calculating Protein Mass
# ========================
#
# In a weighted alphabet, every symbol is assigned a positive real number called
# a weight. A string formed from a weighted alphabet is called a weighted
# string, and its weight is equal to the sum of the weights of its symbols.
#
@sudevschiz
sudevschiz / email_utility.py
Created January 29, 2016 07:39
This utility is to automatically mail a report to User once test-suite execution has been completed and the report is generated using SMTP (Outlook exchange). Code is customised for Selenium automation testing. The scraping location in the report has to be modified.
import smtplib
from os.path import basename
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
import sys
import datetime
import json
@sudevschiz
sudevschiz / sapply_eg.R
Created January 29, 2016 07:32
Example for sapply in R
## Supposed you want to apply an operation to every element in a vector. Efficient way to do it in R is to use sapply / lapply
## Sample vector of 100 observation
x_vec <- rnorm(100)
## Need to find the absolute value of each element
x_abs <- sapply(x_vec,abs)
## The above implementation equivalent to doing x_abs <- abs(x_vec)
@sudevschiz
sudevschiz / split_data.R
Created January 29, 2016 07:18
Snippet to split the data set into training and testing data sets
## Function to split the dataframe
## 143 is just a default seed
splitdf <- function(dataframe, seed=143,splitper) {
if (!is.null(seed)) set.seed(seed)
index <- 1:nrow(dataframe)
trainindex <- sample(index, (splitper/100)*trunc(length(index)))
trainset <- dataframe[trainindex, ]
testset <- dataframe[-trainindex, ]
list(trainset=trainset,testset=testset)