Skip to content

Instantly share code, notes, and snippets.

View gourab5139014's full-sized avatar

G Mitra gourab5139014

View GitHub Profile
@gourab5139014
gourab5139014 / ScreenSqliteJoin_v1.py
Created August 20, 2018 23:25
Extract timestamps for screen events from PhoneLab logs
# coding: utf-8
# In[118]:
import gzip, io, os.path, json
# In[119]:
@gourab5139014
gourab5139014 / create_hr_schema.sql
Created July 3, 2018 16:45
Script to create Oracle XE's HR schema in Postgres
-- Best used for learning purposes. Original developer also has an ER diagram available at https://dbseminar.r61.net/node/32
--create tables
BEGIN;
CREATE TABLE regions
( region_id SERIAL primary key,
region_name VARCHAR(25)
);
CREATE TABLE countries
@gourab5139014
gourab5139014 / geocoded_Tweets.R
Created February 18, 2017 02:11 — forked from dsparks/geocoded_Tweets.R
Gathering Tweets, geocoding users, and plotting them
doInstall <- TRUE
toInstall <- c("twitteR", "dismo", "maps", "ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
searchTerm <- "#rstats"
searchResults <- searchTwitter(searchTerm, n = 1000) # Gather Tweets
tweetFrame <- twListToDF(searchResults) # Convert to a nice dF
userInfo <- lookupUsers(tweetFrame$screenName) # Batch lookup of user info
@gourab5139014
gourab5139014 / longlat.r
Last active October 6, 2015 10:42
The extractLongLatData() uses the ggmap API in R to extract longitude and latitude data for a set of pincodes supplied in a csv file
extractLongLatData <- function(file)
{
library(ggmaps) #In case you dont have the package, use this command - install.packages(ggmaps, dependencies = TRUE)
data <- read.csv(file)
v <- as.list(data["pincode"]) #assuming the attribute containing the pincodes in the supplied CSV file is named "pincode"
pc <- sapply(v,as.character)
pc <- sapply(pc,function(x) { paste(x,"India", sep = " ")}) #change the argument in paste() from "India" to whichever country the pincodes belong to
longlatpc <- geocode(pc, source = "google")
library(xlsx) #In case you dont have the package, use this command - install.packages(xlsx, dependencies = TRUE)
write.xlsx2(longlatpc,'longlatpincode.xlsx')
@gourab5139014
gourab5139014 / wordCloud.r
Created August 27, 2015 14:15
Prepare a wordcloud of opinions regarding selected current affairs in India
tweets <- searchTwitter("hardik patel", n = 1000)
text <- sapply(tweets, function(x) x$getText())
dat3 <- grep("text",iconv(text,"latin1","ASCII",sub = "text"))
dat4 <- text[-dat3]
dat5 <- paste(dat4, collapse = ", ")
corpus <- Corpus(VectorSource(dat5))
tdm = TermDocumentMatrix(
corpus,
control = list(
@gourab5139014
gourab5139014 / ProducerConsumerPattern.java
Last active August 29, 2015 14:10
Producer Consumer Problem in Java using Blocking Queue
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ProducerConsumerPattern
{
public static void main(String args[])
{
BlockingQueue sharedQueue = new LinkedBlockingQueue<>();
@gourab5139014
gourab5139014 / ProducerConsumerTest.java
Last active August 29, 2015 14:10
Implementation of Producer Consumer Problem in Java using threads
import java.util.logging.Level;
import java.util.logging.Logger;
//Producer Consumer using Threads
public class ProducerConsumerTest
{
public static void main(String args[])
{
@gourab5139014
gourab5139014 / URL-Redirection
Created November 28, 2014 14:46
Purpose : One click access to proxy server for blocked pages
javascript: (function() {
a = document.location.href;
a = a.replace(/.*?:\/\//g, "");
b = "http://bcdboot.appspot.com/";
c = b.concat(a);
this.document.location.href = c;
})();
@gourab5139014
gourab5139014 / StringPermu.java
Created February 2, 2014 12:26
Permutations of a String by Recursion using Java
public static void permuteString(String beginningString, String endingString) {
if (endingString.length() <= 1) { System.out.println(beginningString + endingString); }
else {
for (int i = 0; i < endingString.length(); i++) {
try {
String newString = endingString.substring(0, i) + endingString.substring(i + 1); //current character removed from the new string
permuteString(beginningString + endingString.charAt(i), newString);
} catch (Exception e) { System.err.println(e.getMessage()); }
}
}
@gourab5139014
gourab5139014 / showRelationships.sql
Last active March 26, 2024 14:59
SQL Server Script to show all FK relationships in the current database
SELECT
fk.name 'FK Name',
tp.name 'Parent table',
cp.name, cp.column_id,
tr.name 'Referenced table',
cr.name, cr.column_id
FROM
sys.foreign_keys fk
INNER JOIN
sys.tables tp ON fk.parent_object_id = tp.object_id