Skip to content

Instantly share code, notes, and snippets.

View bedantaguru's full-sized avatar

Indranil Gayen bedantaguru

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / nginxproxy.md
Created June 6, 2017 05:31 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@bedantaguru
bedantaguru / server.R
Created June 6, 2017 12:33 — forked from trestletech/server.R
A Shiny app combining the use of dplyr and SQLite. The goal is to demonstrate a full-fledged, database-backed user authorization framework in Shiny.
library(shiny)
library(dplyr)
library(lubridate)
# Load libraries and functions needed to create SQLite databases.
library(RSQLite)
library(RSQLite.extfuns)
saveSQLite <- function(data, name){
path <- dplyr:::db_location(filename=paste0(name, ".sqlite"))
@bedantaguru
bedantaguru / server.R
Created July 1, 2017 18:22 — forked from withr/server.R
Encrypt password with md5 for Shiny-app.
library(shiny)
library(datasets)
Logged = FALSE;
PASSWORD <- data.frame(Brukernavn = "withr", Passord = "25d55ad283aa400af464c76d713c07ad")
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
source("www/Login.R", local = TRUE)
observe({
if (USER$Logged == TRUE) {
@bedantaguru
bedantaguru / demo.R
Last active September 1, 2017 06:43
Defining Variable in R Package Environment
progress_print <- function(){
L <- list(init = function(x) {M <<- x}, step = function() NULL, term = function() NULL)
itr <- 0
M <- 1
L$step <- function(){
itr <<- itr + 1
cat(paste0("Job ", itr, " out of ", M, "\n"))
}
return(L)
}