Skip to content

Instantly share code, notes, and snippets.

@axgle
axgle / done
Created October 14, 2009 11:02
tf-idf
map-reduce-browser: http://www.igvita.com/2009/03/03/collaborative-map-reduce-in-the-browser/
svm-in-ruby: http://www.igvita.com/2008/01/07/support-vector-machines-svm-in-ruby/
rd, wr = IO.pipe
if fork
wr.close
puts "Parent got: <#{rd.read}>"
rd.close
Process.wait
else
rd.close
puts "Sending message to parent"
@axgle
axgle / time ruby a.rb m
Created October 16, 2009 02:58
forkoff IO/Curl etc
===========================
#a.rb
require 'forkoff'
def run(i)
sleep rand
[i,i*i]*":"
end
def m(d)
d.forkoff(200){|i|run(i)}
FriendFeed Implements Schema-less Storage Atop MySQL
http://www.infoq.com/news/2009/03/friendfeed-schemaless-mySQL
class Entity < ActiveRecord::Base
serialize :body
belongs_to :resource,:polymorphic => true
end
class Report < ActiveRecord::Base
has_one :entity,:as=>:resource
end
class Post < ActiveRecord::Base
has_many :entities, :as=>:resource
end
class Module
def field(*args)
args.each do |m|
class_eval do
define_method("#{m}="){|a|
instance_variable_set("@#{m}",a)
}
define_method("#{m}"){
instance_variable_get("@#{m}")
}
<?php
declare(ticks = 1);
$max=5;
$GLOBALS[__FILE__]['_child']=0;
//print_r($GLOBALS);exit;
// function for signal handler
function sig_handler($signo) {
switch ($signo) {
<?php
declare (ticks=1); // Be sure that each signal is handled when it is received.
ini_set("max_execution_time", "0"); // Give us eternity to execute the script. We can always kill -9
ini_set("max_input_time", "0");
set_time_limit(0);
$GLOBALS['mtd_main_thread_pid']=posix_getpid();
$GLOBALS['child'.$GLOBALS['mtd_main_thread_pid']] = 0;
function mtd_sig_handler($signo) {
require 'openssl'
data=`echo 'quit'|openssl s_client -connect google.com:443 2> /dev/null &`
cert = OpenSSL::X509::Certificate.new(data)
ms=cert.methods-Object.methods
ms=ms-ms.grep(/=|to|public_key/)
puts ms.map{|m|[m,(cert.send(m) rescue nil)]}.select{|a,b|!b.nil?}
AD
AE
AF
AG
AI
AL
AM
AN
AO
AQ