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
<?php | |
/* | |
Copyright (c) 2013, Manu Manjunath | |
All rights reserved. | |
Redistribution and use of this program in source/binary forms, with or without modification are permitted. | |
Link to this gist is preferred, but not a condition for redistribution/use. | |
*/ | |
function parse_csv_file($csvfile) { |
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
# zsh prompt: | |
export PROMPT="%/ %% " | |
# zsh styles: | |
export CLICOLOR=1 | |
export STYLE_COLOR_RED="\x1b[31;01m" | |
export STYLE_COLOR_GREEN="\x1b[32;01m" | |
export STYLE_COLOR_BLUE="\x1b[34;01m" | |
export STYLE_UNDERLINE="\x1b[04;01m" | |
export STYLE_BLINK="\x1b[05;01m" |
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
null=None | |
true=True | |
false=False |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>CKEditor</title> | |
<script type="text/javascript" src="./ckeditor.js"></script> | |
<script type="text/javascript"> | |
var editor1, editor1isModified = false; | |
function initialize() { | |
CKEDITOR.replace('editor1', { |
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
function hosts() { | |
if [ $# -eq 0 ]; then | |
hosts_file_num_lines=$(wc -l /etc/hosts | awk '{print $1}') | |
marker_string_frequency=$(grep StevenBlack /etc/hosts | wc -l) | |
if [ "$marker_string_frequency" -gt 1 ]; then | |
echo -e $COLOR_GREEN"/etc/hosts file contains entries for AdBlock"$COLOR_RESET" (contains $hosts_file_num_lines lines)" | |
else | |
echo -e $COLOR_GREEN"/etc/hosts file is right now pristine"$COLOR_RESET" (contains $hosts_file_num_lines lines)" | |
fi | |
elif [ $# -eq 1 ]; then |
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
package manu.sandbox.demos.hadoop; | |
import org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.fs.FileSystem; | |
import org.apache.hadoop.fs.Path; | |
import org.apache.hadoop.io.IntWritable; | |
import org.apache.hadoop.io.LongWritable; | |
import org.apache.hadoop.io.Text; | |
import org.apache.hadoop.mapreduce.Job; | |
import org.apache.hadoop.mapreduce.Mapper; |
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
class NetworkUtils { | |
public static String getLocalIp() { | |
try { | |
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); | |
while (interfaces.hasMoreElements()) { | |
NetworkInterface networkInterface = interfaces.nextElement(); | |
if (networkInterface.isLoopback() || !networkInterface.isUp() || networkInterface.isVirtual() || networkInterface.isPointToPoint()) { | |
continue; | |
} | |
Enumeration<InetAddress> addresses = networkInterface.getInetAddresses(); |
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
package manu.sandbox.utils; | |
import java.math.BigDecimal; | |
import java.math.BigInteger; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.concurrent.*; |
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
#!/usr/bin/python | |
''' | |
Command-line script to get stock price (in USD and local currency) | |
Prerequisite: | |
Python 2.7 | |
Installation: | |
Copy this script to /usr/bin or /bin. | |
Usage: | |
$ stock ZNGA | |
This will get you stock price for company with stock symbol 'ZNGA' |
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
package manu.sandbox.utils; | |
import java.util.*; | |
public class AverageCalculator { | |
private static class FrequencyComparator implements Comparator<Double> { | |
private final Map<Double, Integer> histogram; |
NewerOlder