Skip to content

Instantly share code, notes, and snippets.

View alphaville's full-sized avatar
:octocat:
(De)coding

Pantelis Sopasakis alphaville

:octocat:
(De)coding
View GitHub Profile
@alphaville
alphaville / BlobHelper.java
Created December 10, 2010 03:12
BlobHelper
class BlobHelper {
public static Object toObject(byte[] bytes) {
Object object = null;
try {
object = new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(bytes)).readObject();
} catch (java.io.IOException ioe) {
} catch (java.lang.ClassNotFoundException cnfe) {
}
return object;
@alphaville
alphaville / jaqpot-curl.txt
Created December 10, 2010 04:13
Curl Commands for Jaqpot
# Useful cURL commands:
# Train MLR
curl -X POST -H Accept:text/uri-list -H "Authorization: AQIC5wM2LY4Sfcxd8hvn9mLDaUHiBSUkQnIyrKCdUlsNxKo=@AAJTSQACMDE=#" -d dataset_uri=http://apps.ideaconsult.net:8080/ambit2/dataset/6 -d prediction_feature=http://apps.ideaconsult.net:8080/ambit2/feature/20154 localhost:3000/algorithm/mlr
# PLS Filter
curl -X POST -H "Authorization: AQIC5wM2LY4Sfcxd8hvn9mLDaUHiBSUkQnIyrKCdUlsNxKo=@AAJTSQACMDE=#" -H Accept:text/uri-list -d dataset_uri=http://apps.ideaconsult.net:8080/ambit2/dataset/54 -d target=http://apps.ideaconsult.net:8080/ambit2/feature/22201 -d numComponents=2 localhost:3000/algorithm/plsFilter
@alphaville
alphaville / bibtex-service-cURL.txt
Created December 11, 2010 03:39
Testing BibTeX service (part of Jaqpot)
$ curl -X POST -H "Authorization: AQIC5wM2LY4SfcwddzcQ32/ljZvewpZSVku8ZBRJGvFUnPM=@AAJTSQACMDE=#" \
--data-binary @/home/chung/Desktop/test.bib -H Content-type:text/plain -H Accept:text/uri-list localhost:3000/bibtex -v
* About to connect() to localhost port 3000 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 3000 (#0)
> POST /bibtex HTTP/1.1
> User-Agent: curl/7.19.5 (x86_64-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.15
> Host: localhost:3000
> Authorization: AQIC5wM2LY4SfcwddzcQ32/ljZvewpZSVku8ZBRJGvFUnPM=@AAJTSQACMDE=#
> Content-type:text/plain
@alphaville
alphaville / jaqpot-uri-lists-cURL.txt
Created December 11, 2010 03:54
cURL commands for retrieving lists of resources from Jaqpot
$ curl -X GET -H Accept:text/uri-list localhost:3000/bibtex -v
* About to connect() to localhost port 3000 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 3000 (#0)
> GET /bibtex HTTP/1.1
> User-Agent: curl/7.19.5 (x86_64-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.15
> Host: localhost:3000
> Accept:text/uri-list
>
< HTTP/1.1 200 The request has succeeded
@alphaville
alphaville / runJaqpot.sh
Created December 12, 2010 00:35
Runs Jaqpot server
#Run from within the folder JAQPOT_HOME so that the config file is found under $JAQPOT_HOME/config
/usr/lib/jvm/java-6-sun-1.6.0.22/jre/bin/java -jar "/home/chung/NetBeansProjects/JAQP-OT/dist/JAQP-OT.jar"
@alphaville
alphaville / TaskResourceTest.java
Created May 11, 2011 10:55
Model Training and Prediction Unit Testing
/*
*
* Jaqpot - version 3
*
* The JAQPOT-3 web services are OpenTox API-1.2 compliant web services. Jaqpot
* is a web application that supports model training and data preprocessing algorithms
* such as multiple linear regression, support vector machines, neural networks
* (an in-house implementation based on an efficient algorithm), an implementation
* of the leverage algorithm for domain of applicability estimation and various
* data preprocessing algorithms like PLS and data cleanup.
@alphaville
alphaville / ProhibitRightClick.html
Created December 18, 2011 01:57
Prohibit Right Clicks on your page using JS
<html>
<head>
<script language="javascript">
function click(e) {
if (navigator.appName == 'Netscape' && e.which == 3) {
alert("no right click please")
return false;
}
else {
if (navigator.appName == 'Microsoft Internet Explorer'
@alphaville
alphaville / PassGen.sh
Created December 30, 2011 12:15
Password Generator using linux RNG device
# Allow lowercase and uppercase digits and numbers and the underscore
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c5;
echo '';
# Allow more symbols:
< /dev/urandom tr -dc _A-Z-a-z-0-9#.*$%^* | head -c10;
echo '';
# And even more...
< /dev/urandom tr -dc _A-Z-a-z-0-9#.*$%^*,+=-?/ | head -c10;
@alphaville
alphaville / dataloader.c
Last active December 11, 2015 12:58
Read data from file and store them to a float* (array). C code.
// Header of this file:
#include "dataloader.h"
int load_vector_data(const char* filename, zvect* vector, int* length) {
*length = 0;
*vector = (zvect) malloc(sizeof (zreal) * ALLOCATION_CHUNK);
if (*vector == 0) return OUT_OF_MEM;
int allocated_rows = ALLOCATION_CHUNK;
u_short i = 0;
FILE* fr = fopen(filename, "r");
@alphaville
alphaville / regsol.m
Last active December 11, 2015 16:58
REGSOL returns the regularized Cholesky factorization of a given n-by-n symmetric and positive semi-defnite matrix A given a vector b, i.e. points out to a regularized solution of the system Ax=b.
function [L, J, NJ, D, x] = regsol(A,b)
%REGSOL returns the regularized Cholesky factorization of a given
%n-by-n symmetric and positive semi-defnite matrix A given a vector b, i.e.
%points out to a regularized solution of the system Ax=b.
%
%Syntax:
% [L, J, NJ, x, D] = regsol(A,b)
%
%Input arguments:
%A,b : A positive semidefinite matrix and a vector, of compatible