Skip to content

Instantly share code, notes, and snippets.

View durgaswaroop's full-sized avatar
💭
Having Fun

Swaroop durgaswaroop

💭
Having Fun
View GitHub Profile
@durgaswaroop
durgaswaroop / Kmeans Readme.md
Created June 4, 2016 13:26 — forked from umbertogriffo/Kmeans Readme.md
Step by step Code Tutorial on implementing a basic k-means in Spark in order to cluster a geo-located devices

DATASET

* Download dataset at:
* https://drive.google.com/folderview?id=0B8DR8_DnlFdQM0diSnZJNnZTYlE&usp=sharing

CODE

@durgaswaroop
durgaswaroop / countdown.java
Last active December 28, 2016 19:25
Serial Countdown timers in Android
private class MyTimer extends CountDownTimer {
public MyTimer(final long millisInFuture, final long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onTick(final long milliSecondsStillLeftToFinish) {
long seconds = milliSecondsStillLeftToFinish / 1000;
long mins = seconds / 60;
@durgaswaroop
durgaswaroop / Debugging.md
Last active January 2, 2017 15:30
Intellij Debugging

From the stack overflow question here, If we have a code like this,

public class testprog {
    static void f (int x) {
        System.out.println ("num is " + (x+0)); // <- step into
    }

    static void g (int x) {
-&gt; f(x); // &lt;----------------------------------- current location
@durgaswaroop
durgaswaroop / Android_Errors.md
Last active January 3, 2017 13:38
Android Studio Error fixes

Execution failed for task ':app:clean'. Unable to delete file: ...\app\build\intermediates\exploded.....jars\classes.jar

For this File > Invalidate Cache & Restart

@durgaswaroop
durgaswaroop / exponents.py
Created September 1, 2017 21:06
Python code to solve x**x**x = 10
# Written to calculate value of x such that x**x**x = 10
# Corresponding Quora answer: https://www.quora.com/If-x-x-x-10-what-is-x/answer/DurgaSwaroop-Perla
factor = 100000000
def direction(a, b):
if abs(a - b) < (a / factor):
return 0
elif a - b < 0:
return -1
@durgaswaroop
durgaswaroop / webscraping with python | introduction.py
Created December 19, 2017 19:19
Webscraping with python | Introduction
from bs4 import BeautifulSoup as bs
import urllib.request as ureq
# Website url
freblogg_url = 'http://freblogg.com'
# Fetch the website
website = ureq.urlopen(freblogg_url).read()
# Parse the html of the site with soup
@durgaswaroop
durgaswaroop / REST-API-with-Spark-Microframework.java
Last active December 24, 2017 17:15
Creating RESTful API's with Spark microframework using Java
import spark.Request;
import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletException;
import javax.servlet.http.Part;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
@durgaswaroop
durgaswaroop / Datasets-part1.java
Last active December 27, 2017 08:09
First part of the Datasets in Apache spark
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
import static org.apache.spark.sql.functions.col;
import static org.apache.spark.sql.functions.desc;
public class DataSetMain {
public static void main(String[] args) {
// Initialize Sparksession
@durgaswaroop
durgaswaroop / blog-it.sh
Created December 31, 2017 11:05
Script file that starts the main process
#!/bin/bash
shopt -s expand_aliases
source ~/.bashrc
[ $# -eq 0 ] && {
echo "Title argument missing"
echo "Usage: blog-it <article-title>";
exit 1;
}
@durgaswaroop
durgaswaroop / m2h.py
Last active December 31, 2017 11:13
Markdown to html with pandoc
import sys, subprocess, os.path, time
# alias m2h="python ~\Desktop\30DaysOfBlogging\m2h.py"
# Run the script with `m2h <markdown file>`
# One argument, which is the name of the to be created markdown file
if len(sys.argv) is not 2:
print("ERROR: One and only one argument needed. Markdown file")
sys.exit()