* Download dataset at:
* https://drive.google.com/folderview?id=0B8DR8_DnlFdQM0diSnZJNnZTYlE&usp=sharing
git rebase -i HEAD~3
// To pick three commits including HEAD. So, you get HEAD, HEAD^, HEAD^^
squash a commit ig you want to combine two commits as a single one.
git checkout <commit_hash> -- <file/folder name>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
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) {
-> f(x); // <----------------------------------- current location
Execution failed for task ':app:clean'. Unable to delete file: ...\app\build\intermediates\exploded.....jars\classes.jar
For this File > Invalidate Cache & Restart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
- Optional.empty() - An empty optional
- Optional.of(t) - returns a present Optional containing t. (t must be non-null)
- Optional.ofNullable(t) - returns an Optional with t that can be null
- Never return null from a method that's supposed to return an optional. It defeats the purpose of Optional
- Never do
opt.get()
unless you can prove that the optional is present. - Prefer alternatives to using
opt.isPresent()
followed byopt.get()
- It's generally a bad idea to create an Optional for the sole purpose of chaining methods from it to get a value.
- If an Optional chain is nested or has an intermediate result of Optional<Optional>, it is probably too complex.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
import os | |
# Read all the auth keys from environment variables | |
consumer_key = os.environ["t_consumer_key"] | |
consumer_secret = os.environ["t_consumer_secret"] | |
access_token = os.environ["t_access_token"] | |
access_token_secret = os.environ["t_access_token_secret"] | |
# Using the keys, setup the authorization |
OlderNewer