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
#!/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" |
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
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 |
#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* |
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 |
#!/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. | |
# |
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 |
## 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) |
## 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) |