Skip to content

Instantly share code, notes, and snippets.

@happyrobots
happyrobots / install-linalg.txt
Created March 10, 2011 12:42
Installing Linalg on Fedora 14
1. Download or clone from https://github.com/quix/linalg
( Assume installation folder is linalg )
2. Install dependencies (Lapack, BLAS and legacy Fortran library header)
$ su
# yum install lapack lapack-devel blas blas-devel gcc-gfortran.i686 compat-gcc-34.i686 compat-gcc-34-g77.i686
3. Locate the Fortran header ( g2c.h )
# updatedb
# locate g2c.h
/usr/lib/gcc/i686-redhat-linux/3.4.6/include/g2c.h
# https://github.com/arsduo/koala/wiki
# https://github.com/arsduo/koala/wiki/Test-Users
# routes.rb
match ‘/auth/failure’, :to => ‘profiles#failure’
# profiles_controller.rb
class ProfilesController < ApplicationController
def failure
redirect_to login_url, :flash => {:alert => "Could not log you in. #{params[:message]}"}
@happyrobots
happyrobots / upload.rb
Created February 19, 2011 23:55
quick and dirty file upload
def upload(to_be_uploaded, upload_directory)
uuid = UUIDTools::UUID.random_create
uniq_name = "#{uuid}#{to_be_uploaded.original_filename}"
uploaded_file = File.join(upload_directory, uniq_name)
File.open(uploaded_file, "w") { |f| f.write(to_be_uploaded.read) }
uploaded_file
end
FastVector attributes = new FastVector();
attributes.addElement(numericAttribute);
attributes.addElement(nominalAttribute);
attributes.addElement(stringAttribute);
attributes.addElement(anyOtherAttribute);
attributes.addElement(anotherAttribute);
Instances dataSet = new Instances("dataSetName", attributes, 50);
dataSet.setClassIndex(dataSet.numAttributes() - 1);
@happyrobots
happyrobots / CreatingWekaInstance.java
Created February 13, 2011 21:47
This is just one example of creating an instance in-memory. I think this way is readable and provides enough flexibility on attribute types (numeric, nominal, string).
Instances dataSet = // ...
Attribute stringAttribute = // ...
Attribute nominalAttribute = // ...
int numberOfAttributes = 3;
Instance instance = new SparseInstance(numberOfAttributes);
instance.setDataset(dataSet);
instance.setValue(numericAttribute, 8.8);
Instances dataSet = // ...
// Showing attribute-type pairs of dataSet
// Analogy with SQL: print field and field type of a table
Enumeration attributes = dataSet.enumerateAttributes();
while (attributes.hasMoreElements()) {
Attribute attribute = (Attribute) attributes.nextElement();
System.out.println(attribute.name() + ": " +
Attribute.typeToString(attribute.type()));
}
@happyrobots
happyrobots / CreatingWekaAttributes.java
Created February 13, 2011 20:14
Weka examples how to create attribute with different types.
FastVector validNominalValues = new FastVector(2);
validNominalValues.addElement("male");
validNominalValues.addElement("female");
Attribute nominalAttribute = new Attribute("gender", validNominalValues);
FastVector nullFastVector = null;
Attribute stringAttribute = new Attribute("userId", nullFastVector);
Attribute numericAttribute = new Attribute("humidity");
<html>
<head>
<title>Hello World! This is the title of the page :D</title>
<!-- Style makes your page look prettier. -->
<style>
body {background-color:#ccc}
#content {border:1px solid black}
.bigger {font-size:130%}
</style>
sudo useradd username -G gitosis,admin -d /home/username -s /bin/bash -m
cat /etc/passwd | grep username
# this should output the home directory for username
@happyrobots
happyrobots / SomeBean.java
Created January 14, 2011 22:31
[Managed Bean] Making Primefaces 2.2.RC1 Data Table Filtering works with multiple selection mode.
// .. import statements
// ViewScoped is important for AJAX
@ManagedBean
@ViewScoped
public class SomeBean {
private T[] selectedElementsFromTheList;
private T[] copyOfSelectedElementsFromTheList;
private List<T> theList;