Skip to content

Instantly share code, notes, and snippets.

View tuxdna's full-sized avatar

Saleem Ansari tuxdna

View GitHub Profile
@tuxdna
tuxdna / multipart-decode.rb
Created February 12, 2014 15:51
decode the multi-part messages
#!/usr/bin/ruby1.8
## decode the multi-part messages
require 'rubygems'
require 'mail'
if ARGV[0].nil?
puts "No filename for processing"
else
@tuxdna
tuxdna / engines.scala
Created February 20, 2014 21:35
stroke, steam engine hierarchy in Scala
package oop
object engine {
object FuelLevel extends Enumeration {
type FuelLevel = Value
val Empty, Reserve, Half, Full = Value
}
import FuelLevel._
@tuxdna
tuxdna / MyEngines.java
Created February 20, 2014 21:36
stroke, steam engine hierarchy in Java
package oop;
import java.util.Arrays;
public class MyEngines {
enum FuelLevel {
Empty, Reserve, Half, Full
}
@tuxdna
tuxdna / quicklook.scala
Created February 20, 2014 21:44
Scala session
object quicklook {
// List/Array
val lst = List(1, 2, 3, 4, 5, 6, 7, 8, 10)
val arr = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
// Set / Map
val T = Set("casey", "drew", "jade")
val V = Set("drew", "jade", "glen")
val S = Set("alex", "hunter", "casey", "drew")
@tuxdna
tuxdna / OOPExamples.java
Created February 24, 2014 18:40
simple comparator example
package oop;
class Person {
int age;
String name;
public Person() {
age = 0; // just born
name = "new-born";
}
@tuxdna
tuxdna / testoop.scala
Created February 24, 2014 18:41
simple comparator example in Scala
package oop
object testoop {
def main(args: Array[String]) {
val persons = Array(
new Person(2, "amar"),
new Person(3, "akbar"),
new Person(1, "anthony"),
new Person())
@tuxdna
tuxdna / index.rb
Created March 25, 2014 06:53
Generate static html for all images in sub-folders
#
# Generate static html for all images in sub-folders
# Author Saleem Ansari<tuxdna@gmail.com>
#
folder = "bootconf-2014-pics"
filetypes = ["jpg", "png"]
rows = (filetypes.map{ |filetype|
(Dir.glob("#{folder}/*/*.#{filetype}").map { | img |
@tuxdna
tuxdna / canopy.scala
Created March 25, 2014 15:22
Simple Canopy Clustering algorithm in Scala
package clustering
import scala.collection.mutable
import scala.util.Random
object canopy {
type Point = Tuple2[Int, Int]
def distance(p1: Point, p2: Point) = {
val xdiff = p1._1 - p2._1
@tuxdna
tuxdna / jflex-byaccj-example.md
Last active August 29, 2015 13:57
Compiling JFlex example with BYACC/J

Compiling JFlex example with BYACC/J

Target system

$ uname -svprmio; java -version; javac -version
Linux 3.5.0-23-generic #35~precise1-Ubuntu SMP Fri Jan 25 17:13:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

javac 1.7.0_51

@tuxdna
tuxdna / kmeans-mahout.sh
Last active August 29, 2015 13:57
Fuzzy / KMeans Clustering on Reuters corpus using Mahout 0.7
# WORKFLOW: seqdirectory -> seq2sparse -> {kmeans, fkmeans} -> clusterdump
export HADOOP_USER_NAME=hduser
## Download, unzip, and extract reuters text data from SGML files
WORK_DIR=/tmp/clustering/reuters
mkdir -p $WORK_DIR
curl http://kdd.ics.uci.edu/databases/reuters21578/reuters21578.tar.gz -o ${WORK_DIR}/reuters21578.tar.gz
mkdir -p ${WORK_DIR}/reuters-sgm