Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
import sys
cur_word = None
cur_cnt = 0
word = None
for line in sys.stdin:
line = line.strip()
#!/usr/bin/python
import sys
checkwords = ('for','is','and')
if len(sys.argv)>1:
checkwords = tuple(sys.argv)
checkwords = [ lo.lower() for lo in checkwords ]
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class RowDelimitedFileExample {
private static final String INPUT_FILE = "C:/workspace/Sample.csv";
private static final String ROW_DELIMITED_BY = "\n";
private static final String FIELD_DELIMITED_BY = ",";
@sreesankars
sreesankars / Condition.py
Last active August 29, 2015 14:16
How to write conditions in python without repeating words
#How to write conditions in python without repeating words
#Python 2.x
avariable = 1
q_list = [1,2,3]
q_set = {1,2,3}
q_tuple = (1,2,3)
# Searching for the avariable in a LIST of possible elements; will search for all elements even repeats.
@sreesankars
sreesankars / ProgressMonitor.java
Created February 22, 2015 06:11
A simple ProgressMonitor using few Java 1.8 features like Lambda and the New Date API - LocalDateTime & Duration
package sree.utils;
import java.time.Duration;
import java.time.LocalDateTime;
public class ProgressMonitor {
private static final long tickerInterval = 2*1000; // 2 seconds
private Thread innerThread;
@sreesankars
sreesankars / ReadConfig.java
Last active August 29, 2015 14:15
Avoid escape characters \ " & \\ on execution-strings like JSON, SQL, YAML etc.. in Java
private static final String readSQLQueryFromFile() {
try (Scanner sc = new Scanner(
MyClass.class.getResourceAsStream(MyClass.class
.getSimpleName() + ".sql"))) {
sc.useDelimiter("\\Z");
return sc.next();
} catch (Exception e) {
throw e;
}
}