English

RGTE - Ruby Email filter

According to the developer, RGTE is a small, opinionated email filter which processes and filters incoming email into Maildirs. The current version is 0.0.3. This project looks like it has a lot of potential, but it is still to young to be sure.
If you want to try it you will need to install it with gem but providing a source:

  1. $ [sudo] gem install --source http://rubyi.st/gems/ rgte

The developers reminds us not to forget that we need Tmail
and we need to trail slashes, otherwise it won't work.

Try it and tell me what you think.
Project's site : http://rubyi.st/rgte/

Peach = Thread + each

Parallel Each (for ruby with threads)

It is pretty common to have iterations over Arrays that can be safely run in parallel. With multicore chips becoming pretty common, single threaded processing is about as cool as Pog. Unfortunately, standard Ruby hates real threads pretty hardcore at the present time; however, for some ruby projects alternate VMs like JRuby do give multicores some lovin'. Peach exists to make this power simple to use with minimal code changes.

Functions like map, each, and delete_if are often used in a functional, side-effect free style. If the operation in the block is computationally intense, performance can often be gained by multithreading the process. That's where Peach comes in. In the simplest case, you are one letter away from harnessing the power of parallelism and unlocking the secret of a guilt-free tan. At this stage, the goggles are purely optional.
Using Peach

Suppose you are going about your day job hacking away at code for the WOPR when you stumble upon the code:

  1. cities.each {|city| thermonuclear_war(city)}

Clearly, the only winning move is to declare war in parallel. With Peach, the new code is:
  1. require 'peach'
  2.  
  3. cities.peach {|city| thermonuclear_war(city)}

Requiring peach.rb monkey patches Array into submission. Currently Peach provides peach, pmap, and pdelete_if. Each of these functions takes an optional argument n, which represents the desired number of worker threads with the default being one thread per Array element. For cheaper operations on a large number of elements, you probably want to set n to something reasonably low.

  1. (0...10000).to_a.pmap(4) {|x| process(x)}

Constructing the threads and adding on a few layers of indirection does add a bit of overhead to the iteration especially on MRI. Keep this in mind and remember to benchmark when unsure.
Syntax (without all the words)

  1. require 'peach'
  2.  
  3. [1,2,3,4].peach{|x| f(x)} #Spawns 4 threads, => [1,2,3,4]
  4. [1,2,3,4].pmap{|x| f(x)} #Spawns 4 threads, => [f(1),f(2),f(3),f(4)]
  5. [1,2,3,4].pdelete_if{|x| x > 2} #Spawns 4 threads, => [3,4]
  6.  
  7. [1,2,3,4].peach(2){|x| f(x)} #Spawns 2 threads, => [1,2,3,4]
  8. [1,2,3,4].pmap(2){|x| f(x)} #Spawns 2 threads, => [f(1),f(2),f(3),f(4)]
  9. [1,2,3,4].pdelete_if(2){|x| x > 2} #Spawns 2 threads, => [3,4]

Extracted from the Developers's web site: http://peach.rubyforge.org/

UPDATE: Gracias!, Irlandes Borracho por la correccion en el titulo.

TwitterGrapher

As part of my research for my thesis and other security related implications, I decided to create a program to create a graph of different type of degrees of relationships in twitter. As of now I only being able to grasp a small amount of the total research but so far so good. So I decided to share some of the first graphs and some of my problems.
1. The first graph worth talking about is, The friends of my friends. As shown below the graph is nice, but it does not show any interesting data, besides the fact that almost all share friends in common that I do not have in my list. 2. When I decided to move to higher degrees the application was able to retrieve the data but the library (graphviz) was unable to generate a jpg or png. In the case of a SVG I was able to create the file but, neither Linux nor Linux64 nor OSX where able to load the image. When I tried to generate a png or jpg the gd or the application gave me a core dump. Thanks Juan, for lending me your Linux64 computation time :D.
3. I decided to try with GraphML format instead of the graphviz's dot format. It is worth noting that the degree 2 graph were generated much faster, but again we run into trouble when rendering the huge load of node and edges when I came down to 3 or more degrees. This time was not a matter of not being able to render the images but instead the program I was using Yed, I guess is using an algorithm that does not take into account the fact that I want to see something instead of a huge ball of edges and nodes :D.
4. Again more problems, but this time with the application not handling the loads. Now I decided I was a good time to redesign the application for more scalability and this is what I'm doing so far. So I will post the code as soon as I have that. Cheers and hopefully someone likes or can use this post for something. Ohh.. and this is not finished by far hopefully from here a lot of thing will be created and some new functions will be added to the app. And of course all this is written in RUBY ! :D

Finally mod_rails !

Extrated from mod_rails Homepage:
"Phusion Passenger — a.k.a. mod_rails — makes deployment of applications built on the revolutionary Ruby on Rails web framework a breeze. It follows the usual Ruby on Rails conventions, such as “Don’t-Repeat-Yourself”."

The most important thing, installation:

1. Open a terminal, and type:

  1.      gem install passenger

2. Type:
  1.      passenger-install-apache2-module

And follow the instructions.

Well, enjoy and let the party begin with Apache and Rails. Hopefully, my provider Dreamhost will be deploying this soon to production.

Syndicate content