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
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); |
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
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 |
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
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 |
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
Flash objects do not obey z-index. This is particularly often found on youtube vids.. | |
To solve this, pass wmode parameter with transparent value... like this: www.youtube.com/embed/somecode?wmode=transparent | |
$(function() {}); seems to wait for document ready forever, if it's invoked on a popup. Well um.. or probably because the document is already 'ready', the piece of code inside that function won't be even executed. | |
Instead, put the thing inside that function near the end of </body> tag... please, only if it's a popup. lolplz.. |
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 Array | |
# Largest range with different subsequence, | |
# without any kind of clever optimization. | |
def range_with_diff_subseq(other) | |
self_size = self.size | |
other_size = other.size | |
low = 0 | |
max_pos = self_size < other_size ? self_size : other_size |
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
require "benchmark" | |
require "rspec" | |
module RSpec | |
module Benchmark | |
class Result | |
attr_accessor :slowest, :fastest, :average, :elapsed | |
def initialize(elapsed) | |
@elapsed = elapsed |
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
require 'benchmark' | |
MAX = 10_000_000 | |
Benchmark.bm(3) do |b| | |
b.report("push") do | |
arr = [] | |
MAX.times {|i| arr.push(i.to_s)} | |
end |
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 OptionFilter | |
def initialize(default_opts) | |
@default_opts = default_opts | |
end | |
def generate(param_name, label_value_pairs) | |
@copy = @default_opts.clone | |
@current_param = param_name | |
label_value_pairs.each { |pair| yield pair[0], opts_for(pair[1]) } | |
end |
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
# rm /var/lib/pgsql/data | |
# service postgresql initdb | |
# service postgresql start | |
# vim /var/lib/pgsql/data/pg_hba.conf | |
replace ident with trust |