Skip to content

Instantly share code, notes, and snippets.

View bedantaguru's full-sized avatar

Indranil Gayen bedantaguru

View GitHub Profile
@bedantaguru
bedantaguru / TwitterSentimentAnalysisAndN-gramWithHadoopAndHiveSQL.md Step by step Tutorial on Twitter Sentiment Analysis and n-gram with Hadoop and Hive SQL

PREREQUISITES

* Download JSON Serde at:
* http://files.cloudera.com/samples/hive-serdes-1.0-SNAPSHOT.jar
* and to renominate it as hive-serdes-1.0.jar
  • Add Jar to HIVE_AUX_JARS_PATH of HiveServer2:

    1. Copy the JAR files to the host on which HiveServer2 is running. Save the JARs to any directory you choose, and make a note of the path (create directory in /usr/share/).
get_current_function_call_hierarchy<- function(only_function_names = T){
call_list <- sys.status()$sys.calls
call_list <- call_list[-length(call_list)]
call_list <- call_list[-length(call_list)]
if(length(call_list)==0){
return(character(0))
}
if(!only_function_names){
return(as.character(call_list))
}
@bedantaguru
bedantaguru / R setup for Selenium 3 (Extra).R
Last active November 7, 2016 09:07
R setup for Selenium 3 (Extra)
sel <- startServer(dir = "C:/Dev/Selenium/",
args = c("-port 4455"),
javaargs = c("-Dwebdriver.gecko.driver=\"C:/Dev/Selenium/geko/geckodriver.exe\""),
invisible = F)
firefox_profile.me <- makeFirefoxProfile(list(marionette = TRUE,
webdriver_accept_untrusted_certs = TRUE, # for sites which has expired certificates (sometimes required for internal sites)
webdriver_assume_untrusted_issuer = TRUE, # for the same reason
browser.download.dir = "C:/temp", # download directory. However it's not having any effects as of now.
@bedantaguru
bedantaguru / R setup for Selenium 3.R
Last active December 4, 2020 09:00
Getting RSelenium work with Selenium 3 and Firefox
rm(list=ls())
options(stringsAsFactors = F)
library(RSelenium)
# One can make terminal invisible but initially it helps in detecting any potential problem
# Use proper path for Selenium and geckodriver.exe.
# remember to rename the donwloaded Selenium
sel <- startServer(dir = "C:/Dev/Selenium/",
@bedantaguru
bedantaguru / get_mail.R
Created October 23, 2016 13:34
Get Mails from Gmail in R
# credit goes to http://stackoverflow.com/questions/4241812/how-can-i-send-receive-smtp-pop3-email-using-r
library(rJython)
rJython <- rJython( modules = "poplib")
rJython$exec("import poplib")
rJython$exec("M = poplib.POP3_SSL('pop.gmail.com', 995)")
rJython$exec("M.user(\'<username>@gmail.com\')")
@bedantaguru
bedantaguru / test mail from R.R
Created October 23, 2016 13:28
Demo of Sending mail from R
library(mailR)
send.mail(from="<username of sender>@gmail.com",
to="<username of receiver>@gmail.com",
subject="Test Email",
body="PFA the desired document",
html=T,
smtp=list(host.name = "smtp.gmail.com",
port = 465,
user.name = "<username of sender>@gmail.com",
@bedantaguru
bedantaguru / assignment_operator_in_r.r
Created October 23, 2016 11:55
Assignment Operator in r (an example)
library(RSclient)
con <- RS.connect()
RS.eval(con, ls())
RS.eval(con, y=10) # this is going to give problem
RS.eval(con, y<-10) # this is going to work
RS.eval(con, y) # 10
@bedantaguru
bedantaguru / convert_xls_to_xlsx.R
Last active July 23, 2018 04:05
Convert XLS to XLSX with the Help of RDCOMClient and Excel
library(RDCOMClient)
convert_xls_to_xlsx<- function(in_folder,out_folder, delete_xls=F){
if(missing(out_folder)){
out_folder<- in_folder
}
all_xls<- list.files(in_folder, pattern = ".xls$")