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 'rubygems' | |
require 'nokogiri' | |
require 'net/http' | |
require 'uri' | |
target = 'http://www.buscacep.correios.com.br/servicos/dnec/consultaEnderecoAction.do' | |
if ARGV[0].nil? | |
puts "USAGE:" | |
puts " ruby cep.rb xxxxxxxx" |
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 'test/unit' | |
class Object | |
def blank? | |
if self.respond_to?(:empty?) | |
if self.class == String then self.strip.empty? else self.empty? end | |
else | |
self.nil? | |
end | |
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
$(window).scroll(function(e) { | |
if ($(window).scrollTop() === $(document).height() - $(window).height()) { | |
// ajax! | |
} | |
}); |
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 'eio/eventmachine' | |
TMPFILE = File.expand_path(File.join(File.dirname(__FILE__), "test")) | |
EM.run do | |
EIO.eventmachine_handler | |
EIO.open(TMPFILE, EIO::RDWR) do |fd| | |
EIO.read(fd) do |buf| | |
data = "#{buf} ok" | |
EIO.write(fd, data) do |data| |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>html5 javascript canvas</title> | |
</head> | |
<body> | |
<script> | |
var canvas, context, mouse = { x: 0, y: 0 }; | |
function onDocumentMouseDown(event) { |
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 'rubygems' | |
require 'eventmachine' | |
class Example < EventMachine::Connection | |
def receive_data data | |
send_data "EventMachine minimal server\n\n-----\n#{data}-----\n#{request(data).inspect}" | |
puts request(data).inspect | |
close_connection_after_writing | |
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
mvrilo@ruf-home:~$ ssh -vvv node@mvrilo.no.de | |
OpenSSH_5.3p1 Debian-3ubuntu4, OpenSSL 0.9.8k 25 Mar 2009 | |
debug1: Reading configuration data /etc/ssh/ssh_config | |
debug1: Applying options for * | |
debug2: ssh_connect: needpriv 0 | |
debug1: Connecting to mvrilo.no.de [72.2.126.114] port 22. | |
debug1: Connection established. | |
debug1: identity file /home/mvrilo/.ssh/identity type -1 | |
debug3: Not a RSA1 key file /home/mvrilo/.ssh/id_rsa. | |
debug2: key_type_from_name: unknown key type '-----BEGIN' |
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
# simple example with Sinatra | |
require 'rubygems' | |
require 'sinatra' | |
class Example | |
get '/' do | |
haml :index | |
end | |
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
var buffer = require('buffer').Buffer; | |
function base64(str) { | |
new buffer(str).toString('base64'); | |
} |
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
#!/usr/bin/env node | |
console.log("output string 'test' encrypted"); | |
var crypto = require('crypto'); | |
function md5(str) { | |
var hash = crypto.createHash('md5'); | |
hash = hash.update(str); | |
hash = hash.digest('hex'); |