start new:
tmux
start new with session name:
tmux new -s myname
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
;; 訓練データ | |
(def text_classified_p '(["good" "bad" "good" "good"] | |
["exciting" "exciting"] | |
["good" "good" "exciting" "boring"])) | |
(def text_classified_n '(["bad" "boring" "boring" "boring"] | |
["bad" "good" "bad"] | |
["bad" "bad" "boring" "exciting"])) | |
;;多変数ベルヌーイモデル | |
(defn train [features] |
num_processes = 2 | |
batch_size = 1000 | |
threads_per_process = 10 | |
Parallel.map(0...num_processes, :in_processes => num_processes) do |i|· | |
User.connection.reconnect! | |
User.find_in_batches(:batch_size => batch_size,· | |
:start => (User.count/num_processes) * i,· | |
:conditions => ["id <= ?", (User.count/num_processes)*(i+1)]) do |batch|· | |
Parallel.map(batch, :in_threads => threads_per_process) do |record| |
# A Ruby implementation of | |
# the Viterbi algorithm based on the hidden Markov model (HMM) | |
# | |
# An original Python code: a Wikipedia page "Viterbi algorithm" at | |
# http://en.wikipedia.org/wiki/Viterbi_algorithm | |
# | |
# Author: MISHIMA, Hiroyuki | |
# | |
require 'pp' |
package hbase.sandbox; | |
import java.io.IOException; | |
import org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.hbase.HBaseConfiguration; | |
import org.apache.hadoop.hbase.HColumnDescriptor; | |
import org.apache.hadoop.hbase.HTableDescriptor; | |
import org.apache.hadoop.hbase.client.HBaseAdmin; |
require 'matrix' | |
def regression x, y, degree | |
x_data = x.map {|xi| (0..degree).map{|pow| (xi**pow) }} | |
mx = Matrix[*x_data] | |
my = Matrix.column_vector y | |
((mx.t * mx).inv * mx.t * my).transpose.to_a[0].reverse | |
end |
# http://wiki.apache.org/solr/FAQ#How_can_I_delete_all_documents_from_my_index.3F
# http://wiki.apache.org/solr/UpdateXmlMessages#Updating_a_Data_Record_via_curl
curl "http://index.websolr.com/solr/a0b1c2d3/update?commit=true" -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
I'm amused at the traction this little gist is getting on Google! I would be remiss not to point out that six+ years later I'm still helping thousands of companies on a daily basis with their search index management, by providing managed Solr as a service over at Websolr, and hosted Elasticsearch at Bonsai. Check us out if you'd like an expert helping hand at Solr and Elasticsearch hosting, ops and support!
coll = db.foo | |
coll.drop() | |
coll.insert( { arr : [ { a : 1 } , { b : 2 } , { c : 3 } ] } ) | |
coll.insert( { arr : [ { a : 2 } , { b : 3 } , { c : 1 } ] } ) | |
coll.insert( { arr : [ { a : 3 } , { b : 1 } , { c : 2 } ] } ) | |
coll.ensureIndex( { arr : -1 } ) |