Skip to content

Instantly share code, notes, and snippets.

@zviri
zviri / ReflectionUtils.java
Created December 3, 2013 14:10
Common tasks tasks which can be done via reflection
import java.lang.reflect.Field;
public class ReflectionUtils {
// least invasive method of obtaining protected/private field value
private static <T> T getPrivateFieldValue(Object object, String fieldName) throws Exception {
Field field = object.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
T fieldValue = (T) field.get(object);
field.setAccessible(false);
@zviri
zviri / clusterdump.sh
Created December 3, 2013 10:11
Mahout cheat-sheet
mahout clusterdump \
-dt sequencefile \ # format: {Integer => String}
-d reuters-vectors/dictionary.file-* \ # dictionary: {id => word}
-i reuters-kmeans-clusters/clusters-3-final \ # input
-o clusters.txt \ # output (local filesystem)
-b 10 \ # format length
-n 10 # number of top terms to print
--distanceMeasure org.apache.mahout.common.distance.CosineDistanceMeasure # default is euclidean distance
@zviri
zviri / apache2.conf
Created November 30, 2013 19:05
Apache safe config with mod_proxy
# simple http authentification with htpasswd
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
AuthName "Restricted"
AuthGroupFile /dev/null
AuthType Basic
AuthBasicProvider file
@zviri
zviri / 0_reuse_code.js
Created November 30, 2013 18:57
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