Skip to content

Instantly share code, notes, and snippets.

NSDate *date = [NSDate date];
void (^now)(void) = ^ {
    NSLog(@"The date and time is %@", date);
};
now();
sleep(5);
date = [NSDate date];
now();
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Tutorial">
<do type="accept" label="Answer">
<go href="#card2"/>
</do>
<p><select name="name">
require "nokogiri"
require "hpricot"
require "open-uri"
#on my macbook
#$ ruby speedtest.rb
#uri took: 4.539837
#hpricot took: 3.490182
#nokogiri took: 6.273096
$ gem install mongo_ext
Building native extensions. This could take a while...
ERROR: Error installing mongo_ext:
ERROR: Failed to build gem native extension.
/Users/mseeger/.rvm/rubies/rbx-1.0.0-rc2/bin/rbx extconf.rb
checking for asprintf()... yes
checking for ruby/st.h... yes
checking for ruby/regex.h... yes
checking for ruby/encoding.h... no
@rb2k
rb2k / bla.rb
Created February 25, 2010 15:31
o = OrderedHash.new
o[:findandmodify] = 'to_crawl'
o[:sort] = {:incoming_links => -1}
o[:remove] = true
o[:limit] = amount
jobs = queue.db.command(o)["value"]
puts jobs.inspect
jobs.each do |page|
...
@rb2k
rb2k / harvard
Created February 24, 2010 15:43
Purposeful conflict resolution by adequate and problem-conscious acting. The Four Action Principles
of the Harvard Concept easily modified and supplemented from the practical experience of the authors:
* Handling people separately from problems and tasks (Separation of relationship level - information level – functional level).
* Place goals, interests and needs and not personal opinions and positions in the middle.
* Before making a decision, come up with alternative solutions which bring advantages to both partners.
* Agree on neutral criteria for the evaluation of the developed solutions and make a decision using these criteria.
require "rubygems"
require "eventmachine"
require 'em-http'
class Tester
def crawl(url)
EM.run do
http = EM::HttpRequest.new(url.to_s).get
<stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" id="c4ca02e3-8867-4fd9-b879-2b8030075d21" from="messi.mi.hdm-stuttgart.de" version="1.0" xml:lang="en">
<stream:features>
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>PLAIN</mechanism>
</mechanisms>
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
<auth xmlns="http://jabber.org/features/iq-auth" />
</stream:features>
</stream:stream>
­
<stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" id="8bb36896-d1d4-4b8e-a534-483d6f18e9ab" from="messi.mi.hdm-stuttgart.de" version="1.0" xml:lang="en">
<stream:features>
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>PLAIN</mechanism>
</mechanisms>
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
<auth xmlns="http://jabber.org/features/iq-auth" />
</stream:features>
</stream:stream>
­
require "rubygems"
require "sinatra"
require "pstore"
require "openssl"
require "base64"
configure do
set :data_store, PStore.new("users.pstore")
end