Skip to content

Instantly share code, notes, and snippets.

View arunreddy's full-sized avatar
🎯
Focusing

Arun Reddy arunreddy

🎯
Focusing
View GitHub Profile
@arunreddy
arunreddy / TestGist
Created March 11, 2012 03:11
Test: Gist
This is my first gist.
@arunreddy
arunreddy / index.html
Created March 11, 2012 05:48
HTML: index
<html>
<head>
<title></title>
</head>
<body>
@arunreddy
arunreddy / bash_template.sh
Created March 19, 2012 13:40
Bash : template
#-----------------------------------------------------------------------------------------------
# Check for number of arguments, Initialize them.
#-----------------------------------------------------------------------------------------------
[[ -n $1 && -n $2 && -n $3 && -n $4 && -n $5 && -n $6 ]] || { echo "Invalid input.Check the usage.." >&2; usage; exit 1; }
# debecho (debug-echo), by Stefano Falsetto ###
# Will echo passed parameters only if DEBUG is set to a value. ###
debecho () {
if [ ! -z "$DEBUG" ]; then
@arunreddy
arunreddy / bash_snippets.sh
Created June 3, 2012 09:24
Bash shell snippets.
# To get the current directory.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@arunreddy
arunreddy / ReadContentFromFile.java
Created June 9, 2012 13:20
Read content from file.
private static String readFile() throws IOException {
FileInputStream stream = new FileInputStream(new File("String.txt"));
try {
FileChannel fc = stream.getChannel();
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
/* Instead of using default, pass in a decoder. */
return Charset.defaultCharset().decode(bb).toString();
}
finally {
stream.close();
public String getThreadStatus()
{
StringBuffer buf = new StringBuffer();
Thread[] daemonThreads = getAllDaemonThreads();
for (Thread thread : daemonThreads) {
if (thread.getName().contains("Solrj")) {
buf.append(thread.getName() + "--" + thread + "\n");
}
}
return buf.toString();
@arunreddy
arunreddy / HHMMSS.java
Created August 6, 2012 18:47
Seconds to HH MM SS
private String formatIntoHHMMSS(long secondsInput)
{
int hours = (int) (secondsInput / 3600), remainder = (int) (secondsInput % 3600), minutes = remainder / 60, seconds =
remainder % 60;
return ((hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":"
+ (seconds < 10 ? "0" : "") + seconds);
}
@arunreddy
arunreddy / 0_reuse_code.js
Created June 18, 2014 03:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@arunreddy
arunreddy / CommandUtils.java
Created June 19, 2014 23:19
Execute command in java.
CmdUtils.executeCommand("SMILExtract -C /media/MEDIA02/msthesis/emobase2010.conf -I example_audio1.wav -O targetFile.arff -label1 );
public static String executeCommand(String command) {
StringBuffer output = new StringBuffer();
Process p;
try {
p = Runtime.getRuntime().exec(command);
p.waitFor();
@arunreddy
arunreddy / haarFeatures.c
Created September 19, 2014 11:44
Calculate number of haar features - Viola Jones Face Detection.
#include <stdio.h>
int main()
{
int i, x, y, sizeX, sizeY, width, height, count, c;
/* All five shape types */
const int features = 5;
const int feature[][2] = {{2,1}, {1,2}, {3,1}, {1,3}, {2,2}};
const int frameSize = 24;