Posted: July 14th, 2009 | Author: FreedomCoder | Filed under: Open Source, Programming, Security | Tags: Open Source, Programming, Ruby, Security | No Comments »
Finally, after weeks of work, the first stable Beta of ESearchy is up and running in github’s gem repository.
Esearchy is a small library capable of searching the internet for email addresses. Currently, the supported search methods are engines such as Google, Bing, Yahoo, PGP servers, GoogleGroups, Linkedin, etc , but I intend to add many more.
Also, the library searches inside .pdf, .docx, .xlsx, .pptx, asn and .txt files for emails addresses and adds them to the list of found accounts. Finally, we have support for .docs files but for now only in Windows Platforms. (For more information visit: Github .
In order to install it you simple add the repository and then install the gem, as shown below.
-
> gem sources -a http://gems.github.com
-
> gem install FreedomCoder-esearchy
Once the gem is installed, you can create a new search opening and/or use the “esearchy” CLI tool but it’s really basic so far and it does not has all of the plugins.
-
require ‘esearchy’
-
-
ESearchy::LOG.level = ESearchy::APP #Output to the stdout.
-
-
ESearchy.create "domain.com" do |d|
-
d.yahoo_key = "yourAPIkeygoeshere"
-
d.bing_key = "yourAPIkeygoeshere"
-
# if you want to also look in LinkedIn
-
d.company_name "Company Name"
-
#A user is needed in order to search within Linkedin
-
d.linkedin_credentials "myuser@linkedin.com", "mypwd"
-
d.maxhits = 50
-
d.search
-
d.save_to_file "company_emails.txt"
-
end
If you have any comments, issues or want to submit a bug please do so on
http://github.com/FreedomCoder/esearchy/issues
Hopefully it will be useful to you.
(Via 自由編碼人.) Original Link: First stable beta of ESearchy is out!
Posted: June 13th, 2009 | Author: FreedomCoder | Filed under: Open Source, Programming | Tags: Heroes, Open Source, Programming, Ruby | 1 Comment »
This week I’m happy to tell you about a new set of articles which will be appearing here on the Rails blog called “Community Highlights”. This new series will feature people/projects/sites from the Rails community that may deserve a little extra recognition.
This week, we’re going to start with a few people who received awards on stage at Railsconf 2009, this years Ruby Heroes.
Brian Helmkamp

Brian has been a contributing member of the Ruby community for 4 years now, but is most well known for his testing library
Webrat. He’s a contributer to Rails, RSpec, Rubinius, and is a co-author on the recent
RSpec Book. More recently he’s been helping out the Rails core team with Rack:Test, and Rack:Debug.
His Blog: http://www.brynary.com/
Twitter: brynary
Aman Gupta

Aman has taken over the maintenance, new features, and the recent releases of
EventMachine, which is an invaluable tool for writing fast ruby applications. He’s also the author behind
amqp &
xmpp4em gems which are deployed far and wide.
Github: http://github.com/tmm1
Twitter: tmm1
Luis Lavena

Pat Allan

Pat is the mastermind behind
Thinking Sphinx which has become a standard when it comes to full-text search in Rails. He’s also one of the guys that has helped create the phenomenon known as
Railscamp, where I hear he makes some killer pancakes.
His Blog: http://freelancing-gods.com/
Twitter: Pat
Dan Kubb

Dan been tirelessly working on one of the hardest Ruby projects around,
DataMapper. He became the official maintainer after Sam Smoot and since then has completely rewritten the test suite to give DataMapper better coverage, has come up with a viable path to completion, and is currently working on making sure DataMapper works great with Rails 3.
Github: http://github.com/dkubb
Twitter: dkubb
John Nunemaker

Those are your six Ruby Hero’s for 2009. If you’re interested you can also watch a video of the award ceremony which talks more about the methodology about how they were chosen and see 5 of these guys receive their awards on stage at Railsconf 2009.
(Via Riding Rails.) Original Link: Community Highlights: Ruby Heroes
Posted: June 13th, 2009 | Author: FreedomCoder | Filed under: Open Source, Programming, how-to | Tags: Open Source, Programming, regexp, Ruby | No Comments »
Como les conté acá y acá, estoy escribiendo un tokenizador para un wiki que estoy programando. Y hoy me encontré con una cosa muy extraña de las expresiones regulares.
En ruby la función match sirve para buscar el primer match de una regex dentro de un string. Por ejemplo (usando el irb):
irb(main):001:0> m = /a/.match "babab"
=> #<MatchData "a">
irb(main):002:0> m.pre_match
=> "b"
irb(main):003:0> m[0]
=> "a"
En particular, el pre_match es lo que está antes del match en el string. También según había entendido (mal) /\Z/ matchea con el final del string. Por ejemplo:
irb(main):004:0> m = /\Z/.match "hola"
=> #<MatchData "">
irb(main):005:0> m.pre_match
=> "hola"
Pero, /\Z/ tiene un comportamiento muy extraño, aunque documentado, cuando el último caracter antes del final es un \n. Lo que pasa es que el pre_match queda ¡sin el\n del final!. Lo muestro en el irb:
irb(main):006:0> m = /\Z/.match "\n"
=> #<MatchData "">
irb(main):007:0> m.pre_match
=> ""
Para que no se manduque el \n, hay que usar /\z/ (¡en minúscula!):
irb(main):008:0> m = /\z/.match "\n"
=> #<MatchData "">
irb(main):009:0> m.pre_match
=> "\n"
Por lo tanto tuve que tocar el tokenizer, ahora la función de initialize quedó así (miren el cambio de la "Z" a "z"):
def initialize( delimiters )
@delimiter_list = [[/\z/, :finish]] +
delimiters.to_a.map { |k,arr| arr.map { |re| [re, k] } }.inject([]) { |ac,ps| ac + ps }
@match_cache = nil
end
Y el test que captura el problema que genera usar \Z en vez de \z quedó así:
def test_carriage_return_ending
tok = Tokenizer.new( :a_kind => [/!/] )
tok.source = "bang!\n"
tok.next_token
assert_equal true, tok.has_next?
tok.next_token
assert_equal true, tok.has_next?
assert_equal "\n", tok.next_token[0].to_s
assert_equal false, tok.has_next?
end
Happy hacking,
Aureliano.
(Via aurelianito.) Original Link: Pequeñas delicias de las expresiones regulares
Posted: June 11th, 2009 | Author: FreedomCoder | Filed under: Open Source, Programming | Tags: css, html, Open Source, Programming, Ruby | No Comments »
Tomando como base lo que dice en este post, hice un script en ruby que genera html con clases que se pueden poner coloritos con css:
require 'rubygems'
require 'syntax/convertors/html'
class Syntax::Convertors::HTML
def convert( text, klass="" )
html = "<pre class=\"#{klass}\">"
regions = []
@tokenizer.tokenize( text ) do |tok|
value = html_escape(tok)
case tok.instruction
when :region_close then
regions.pop
html << "</span>"
when :region_open then
regions.push tok.group
html << "<span class=\"#{tok.group}\">#{value}"
else
if tok.group == ( regions.last || :normal )
html << value
else
html << "<span class=\"#{tok.group}\">#{value}</span>"
end
end
end
html << "</span>" while regions.pop
html << "</pre>"
html
end
end
convertor = Syntax::Convertors::HTML.for_syntax "ruby"
puts convertor.convert( $stdin.read, "ruby" )
En el script monkeypatchié un toque para que agregue la clase “ruby” al tag pre que engloba todo el código y aparte estoy usando estos estilos:
<style>
pre.ruby {
background-color: #ffffcc;
color: #000000;
padding: 10px;
font-size: 1.1em;
overflow: auto;
margin: 4px 0px;
width: 95%;
border: thin dashed;
}
.ruby .normal {}
.ruby .comment { color: #005; font-style: italic; }
.ruby .keyword { color: #A00; font-weight: bold; }
.ruby .method { color: #077; }
.ruby .class { color: #074; }
.ruby .module { color: #050; }
.ruby .punct { color: #447; font-weight: bold; }
.ruby .symbol { color: #099; }
.ruby .string { color: #944; }
.ruby .char { color: #F07; }
.ruby .ident { color: #004; }
.ruby .constant { color: #07F; }
.ruby .regex { color: #B66; }
.ruby .number { color: #D55; }
.ruby .attribute { color: #377; }
.ruby .global { color: #3B7; }
.ruby .expr { color: #227; }
</style>
Una cosa más, si estás viendo este post en otro lugar que no sea aurelianito.blogspot.com no vas a ver el resaltado de sintaxis (ya que no va a tener los estilos).
Hasta la próxima,
Aureliano
(Via aurelianito.) Original Link: Syntax highlighting de Ruby en mi blog
Posted: May 19th, 2009 | Author: FreedomCoder | Filed under: Programming, Windows, how-to | Tags: one-click, Ruby, Windows | No Comments »
“
I must say that my skills to ask for something are really lacking, and my design skills are even worse.
So, I’m bringing this topic to the table, seeking for ideas on how to improve the Ruby on Windows image beyond just code.
I’m willing to offer money to pay for it, since I’m quite aware that Open Source and contributions don’t put food on the table.
Of course, I’m not rich, so the balance needs to be found
So, what is the idea:
- Build the website with Radiant or a simple CMS over Ruby
- Design needs to be simple and provide access to:
- News feed (small articles)
- Download info and links
- Getting Started Resources (info and links)
- Contribute (RubyForge and GitHub info)
- Support (access to mailing list and forums of interest)
- Initial artwork (logo and iso) already exist
- Application icons can be highly improved
For the record: there is no need to be a Windows user or designer, so people on Linux and OSX are welcome
If there is more interest, maybe a Bounty can be opened, but time, feedback and community response will tell.
Please, comment and pass the message!
“
(Via DEV_MEM.dump_to(:blog) – Multimedia systems blog.) Original Link: RubyInstaller: One-Clicks need a new home, can you help him?
Posted: May 6th, 2009 | Author: FreedomCoder | Filed under: Open Source, Programming | Tags: Open Source, Programming, Ruby, TCP | No Comments »
“Estuve programando un bouncer, usando como base el load balancer que hice el año pasado. Un bouncer es un programa que poner un server TCP en un puerto y cada vez que recibe una conexión abre una conexión a otro lado y las ‘ata’, haciendo que el server al que se conecta le conteste al cliente que se conecta a él.
En mi caso lo programé para tener una salida controlada del entorno de máquinas virtuales que estoy armando para tener más ordenadas las cosas en el trabajo.
Por si les interesa, acá abajo pongo el código completo.
#!/usr/bin/env ruby
# == Synopsis
#
# redirect.rb: Redirects TCP connections to distant machines. Handles simultaneously many connections.
#
# == Usage
#
# ruby redirect.rb [OPTION]
#
# -h, --help:
# Show help
#
# --ip ip, -i ip:
# Accept connections from ip (default 127.0.0.1)
#
# --port port, -p port:
# Listen on port (default 12345)
#
# --target ip:port, -t ip:port
# Connect to ip:port (default 127.0.0.1:23456)
#
require 'getoptlong'
require 'rdoc/usage'
require 'socket'
class Redirect
def initialize( source_ip, listening_port, target_ip, target_port )
@source_ip = source_ip
@target_ip = target_ip
@target_port = target_port
@server_socket = TCPServer.new( "", listening_port )
@server_socket.setsockopt( Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1 )
@descriptors = [ @server_socket ]
@next_step = {}
end
def handle_new_connection
incoming = @server_socket.accept
if incoming.peeraddr[3] == @source_ip
begin
outgoing = TCPSocket.new( @target_ip, @target_port )
@next_step[ incoming ] = outgoing
@next_step[ outgoing ] = incoming
@descriptors += [ incoming, outgoing ]
rescue
silent_close( incoming )
end
else
silent_close( incoming )
end
end
def silent_close( sock )
begin
sock.close
rescue
#do nothing intentionally
end
end
def propagate(sock)
next_sock = @next_step[sock]
next_sock.write(sock.read_nonblock(1000 * 1000))
end
def finish_connection(sock)
next_sock = @next_step[sock]
[ sock, next_sock ].each do
|s|
silent_close(s)
@descriptors.delete(s)
@next_step.delete(s)
end
end
def run
loop do
connections = select( @descriptors )
connections[0].each do
|sock|
if sock == @server_socket then
handle_new_connection
else
begin
sock.eof? ? finish_connection(sock) : propagate(sock)
rescue
finish_connection(sock)
end
end
end
end
end
end
if $0 == __FILE__ then
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--ip', '-i', GetoptLong::REQUIRED_ARGUMENT ],
[ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
[ '--target', '-t', GetoptLong::REQUIRED_ARGUMENT ]
)
ip = '127.0.0.1'
port = '12345'
target = '127.0.0.1:23456'
opts.each do
|opt, arg|
case opt
when '--help'
RDoc::usage
exit
when '--ip'
ip = arg
when '--port'
port = arg
when '--target'
target = arg
end
end
port = port.to_i
target = target.split(":")
trap("SIGINT") do
exit
end
Redirect.new(ip, port, target[0], target[1].to_i).run
end
“
(Via aurelianito.) Original Link: Bouncer básico en ruby
Posted: May 5th, 2009 | Author: FreedomCoder | Filed under: Uncategorized | Tags: one-click-installer, Programming, Ruby, Windows | No Comments »
“
I wont be lame and say been a while since last blogged, which is true, but is not the reason I’m writing this.
I’ll like to provide a better look on what’s going on at RubyInstaller project, clear out some repeating questions and give hope to people.
Please keep reading if you’re interested (will try to make it short, I promise).
Current One-Click Installer – Stable State
I keep getting several emails about current installer (labeled 186-27 RC2). While it says Release Candidate 2, it has proven to be really stable, not getting any new report of issues or major bugs in the installer, Ruby or RubyGems.
So even it says RC2, it is stable people, please use it (I do).
I’ve been working in the new installers, that’s why there was no updated version.
1.8.6, 1.8.7, 1.8.x?
I tried to explain why RubyInstaller project is sticking with 1.8.6 for 1.8.x line of Ruby support. It seems needs further explanation.
Lot of packages bundled in current installer, see for yourself here
Most of those haven’t been updated in years, which mean that manually I need to go and patch all those to make them work with 1.8.7 due some changes in the extensions and even some features (cough, incompatibilities) back-ported from 1.9.x development.
Doing that amount of work is beyond RubyInstaller project job or role. I’ve invested lot of this time fixing several projects for Windows compatibility and provide tools to ease the cross platform integration (rake-compiler).
We can’t do more than that. I can’t do more than that.
I cannot endorse 1.8.7 usage or support it, since I’m not an active user of that particular version.
So go ahead, checkout the Subversion repository of current installer like this:
svn co http://rubyinstaller.rubyforge.org/svn/trunk/installer-win2/ current-one-click
Read the instructions and build your own version of 1.8.7.
Don’t have a VC6 license required to build it? then clone the MinGW version over here
All the code is out there, all the instructions are there. There is no rocket science about the process, just time, your time.
When will be a 1.9 One-Click Installer?
When people start helping out, seriously.
On a weekly basis I get errors from people facing issues with several Gems, way beyond the scope of RubyInstaller project. Even so, I try to help them out.
That is a time consuming tasks, being the only one with all the world knowledge of Windows…
Seriously guys, do you think I know all the answers to all your Windows projects under X, Y, Z version of OS, Rails, permissions, libraries and gem combination? I’m only human. /rant
Anyhow, progress has been made in getting both 1.8.x and 1.9.x working with the new MinGW based installer. Test packages (compressed with 7-zip) are available at the following URL:
http://rubyinstaller.org/downloads/
Be aware that no bug report will be accepted for those versions, yet.
Also, keep in mind that 1.9.1-p0 doesn’t complete it’s own tests on Windows, which is a real problem to proper distribute an official version.
When the Installers are going out for 1.8.6 and 1.9?
The updated-installers branch at GitHub contains the MSI recipes to build both 1.8 and 1.9 versions of the installer.
The following is the list of things that needs more work before release:
- Installers requires Administrative privileges (elevated rights).
Looking into a way to avoid it.
- Does not ask about adding the Ruby to the
PATH.
It does always, which make co-existence with other Ruby a problem.
- Lot of your gems will be broken.
You could blame Ruby and rbconfig for this. Basically, MinGW and VC6, even they use the same CRT, they are marked as different platforms (i386-mingw32 and i386-mswin32).
Several gems evaluate for mswin32 (even worse, some of them check RUBY_PLATFORM with win32 (see this post)
Cannot fix all those gems, so is time for you to contribute too.
What can you do to help?
I was waiting for that question to show up!
Download those versions (including the fake DevKit), put your helmet, gloves and start using it like I do. Some tips:
- Add the compiler to the
PATH when installing gems that contains extensions.
If you gem fails during installation and shows the Building native extensions legend that means you need the compiler around
- Check for
RUBY_PLATFORM in the gems
If the gem doesn’t work after that, peek into the gem code for RUBY_PLATFORM conditions and see if mingw is being considered
- Ask the developer to provide native versions of the gem
If the gem requires several libraries and other stuff. Politely request the gem author to create a native binary of that gem for Windows.
Point him to rake-compiler project, and some projects that includes tasks for building cross platform packages.
As a last resource, ask them join rubyinstaller-users list and ask questions about to improve the cross-platform compatibility of their projects.
Hint: latest json gem needs some love
Final words
I come from the broadcast video industry, where a release early, release often approach doesn’t work since thousands of dollars can be lost for a couple of seconds downtime.
Releasing something with so many quirks will make people angry, and will not help on solve or improve the image Ruby on Windows already have.
But is as much I can do, it is time for you, Ruby developer, either on Linux, OSX or Windows to take care.
We are talking about Ruby and the Ruby Community, not just Windows.
“
(Via DEV_MEM.dump_to(:blog) – Multimedia systems blog.) Original Link: RubyInstaller – State of One-Click
Posted: April 28th, 2009 | Author: FreedomCoder | Filed under: Open Source, Programming | Tags: java, Programming, Ruby | No Comments »
“
Why would any self-respecting Java developer care about Ruby? Ruby is a general-purpose scripting language created 10 years ago in Japan. Contrary to popular belief, it is a pure object-oriented language. Unlike Java technology, Ruby has no scalars, so everything, including integers, are first-class objects. Ruby’s syntax borrows heavily from Smalltalk, Python, and Ada. Like the Java programming language, Ruby is a single inheritance language, but it offers some advanced features that Java technology does not, such as closures (think anonymous inner classes on steroids) and mix-ins (similar to interfaces, but less tightly bound to the class). Ruby is also highly portable, running on all major operating systems.
Ruby is also red-hot right now. People are starting to use it for the types of applications where it excels. Because it is interpreted and uses dynamic typing, you can do all sorts of magic tricks at run time that are very difficult in Java. One of the surprising capabilities enabled by dynamic typing and expressive syntax is the ability to create domain-specific languages in Ruby that allow you to work at a higher level of abstraction, away from the ‘raw’ syntax of the language. Ruby on Rails is a framework for creating Web applications backed by databases that shows this elegance. Rake, Ruby’s version of Make and Ant rolled into one, is another example of this powerful use of the language.
The other reason to start playing with Ruby is that all the cool kids are doing it. Many of the people who recognized that Java technology was going to be important back in 1996 (like Glenn Vanderburg, Bruce Tate, and Martin Fowler) are heavily involved in Ruby now. Even if you aren’t going to change all your development efforts to Ruby, maybe it’s time you took a look at this language.
One of the main limiting factors to widespread development in Ruby is a good development environment (for those who don’t want to learn Emacs). The RDT changes that. What better way to experiment with Ruby than in your favorite IDE, Eclipse?
My favorite IDE is EMACS and you ?
Tinix./
“
(Via TinixTech’s Weblog.) Original Link: Why Ruby…??? My Reasonable Question
Posted: April 3rd, 2009 | Author: FreedomCoder | Filed under: Open Source, Programming, Rails, github | Tags: Flash, github, Plugins, Programming, Rails, Ruby | No Comments »
En la última semana estuve trabajando en agregar nuevas funcionalidades a un sitio de un cliente y entre los pedidos estaba una especie de Fotoblog para los usuarios (y bue, hay que pagar las cuentas a fin de mes
).
La cosa salió rápido, usando Paperclip que guarda las imágenes que se suben, se muestra en orden, etc, nada del otro mundo. Pero hablando con el cliente surgió la idea de hacer que el usuario se pueda tomar una foto directamente desde la web usando su webcam, así que después de decir “si, se debe poder hacer” mentalmente me salió un “doh!, que dije!“. Lo último que se dijo en esa reunión fue “Lo quiero”
.
Ya había visto juegos flash que utilizan la webcam así que empecé por ahí, para ver como sacaban un frame del video, lo cual era muy fácil. Lo siguiente era serializarla. A falta de algo mejor hice un serializador de imágenes muy pedorro, pero que anda (aunque es lento), que envía por POST la información de cada pixel.
La parte de Ruby fue fácil y decidí encapsularla en un plugin de Rails para poder reutilizarlo luego o por si a alguien más le sirve
. Además se puede integrar con Paperclip o AttachmentFu para hacer la persistencia de la imagen en donde sea.
La única parte que usa Flash es el capturador de la cámara, porque otra no quedaba, pero luego el botón para tomar la foto y los eventos se manejan todo por Javascript.
El plugin tiene varios TODOs, pero por si a alguien le sirve está en github.
(Via El Futirifoken.) Original Link: Take A Photo – Fotos instantáneas desde tu web