Skip to content

Instantly share code, notes, and snippets.

@elisehuard
elisehuard / lark_template.rb
Created August 21, 2009 13:58
removing states and metric-fu for rails rumble
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
gem install hanna
def post(method_name, options = {}, body = nil)
request_body = body.blank? ? encode : body
if new?
# connection.post(custom_method_new_element_url(method_name, options), request_body, self.class.headers)
# elise fix
connection.post(custom_method_new_element_url(method_name, options), request_body, self.class.headers).tap do |response|
.id self= id_from_response(response)
load_attributes_from_response(response)
end
self
static VALUE
ossl_x509req_add_unstructuredName(VALUE self, VALUE name)
{
X509_REQ *req;
char* s;
GetX509Req(self,req);
s = StringValuePtr(name);
if (X509_REQ_add1_attr_by_NID(req, NID_pkcs9_unstructuredName,MBSTRING_ASC,s, -1) != 1) {
ossl_raise(eX509ReqError,NULL);
@elisehuard
elisehuard / gist:333827
Created March 16, 2010 10:30
awesome wm and rubymine
# add in .zshrc or .bashrc
# or in rubymine's startup script :)
export AWT_TOOLKIT='MToolkit java -jar weka.jar'
# helpers for local :javascripts and :stylesheets
# add
# yield :javascripts
# yield :stylesheets
# in your header
def load_javascripts(*scripts)
load_content(:javascripts,*scripts) do |script|
javascript_include_tag script
end
require 'nokogiri'
module Nokogiri
module XML
class Node
BLANK = /^[ \n]*$/
# Comparing with other node
# - same name
# - same attributes
@elisehuard
elisehuard / gist:630980
Created October 17, 2010 16:20
concurrent sieve of erathostenes - analogy with go example
-module(sieve).
-export([run/1]).
run(M) ->
Numbers = lists:seq(3, M),
Startpid = self(),
spawn_link(fun() -> prime_filter(Startpid, 2, Numbers) end),
gather().
gather() ->
@elisehuard
elisehuard / gist:635097
Created October 19, 2010 20:55
parallel quicksort
package main
import (
"fmt"
"os"
)
type request struct {
data []int
replyChannel chan []int
}
@elisehuard
elisehuard / gist:819022
Created February 9, 2011 18:58
(minimal) mongrel2 handler in ruby
require 'zmq'
require 'json'
handler_ctx = ZMQ::Context.new(1)
# receive and response for mongrel2 handlers
# queue address corresponds to what's in the configuration
recv_queue = handler_ctx.socket(ZMQ::PULL)
recv_queue.connect("tcp://127.0.0.1:9999")