Archive

Archive for the ‘General’ Category

Tries: la pronunciación se deja como ejercicio para el lector.

April 28th, 2011 Serabe No comments

El repositorio de github de trie. Tomad y usad todos de él.

Para ver el artículo de succint trie, añadid en Google Reader el feed http://stevehanov.ca/blog/index.php?atom El artículo se llama “Succint Data Structures: Cramming 80,000 words into a Javascript file“.

Próximamente la presentación en slideshare.

Próximamente el vídeo.

Cuando vea en qué formato sale lo de OvationApp, lo subo también (y también próximamente)

 

article clipper Tries: la pronunciación se deja como ejercicio para el lector.
 
share save 171 16 Tries: la pronunciación se deja como ejercicio para el lector.
Categories: General Tags:

Introducing rinzelight 0.0.2

October 17th, 2010 Serabe No comments

I started writing rinzelight long time ago. Exactly, I started on February. Sadly, since I wasn't getting a few points about Clojure, I stopped working on it twenty days after for half a year.

But do not let me digress. Rinzelight is finally released! Actually, rinzelight 0.0.2 is released! But let me introduce you to rinzelight.

Opening an image.

Just use rinzelight.image namespace. Then, just provide read-image of a filepath or an InputStream. Just like this:

A hash?

Yes. Four fields: image, format, width and height.

It's an image. Let me see it!

Command your repl to display-image.

What about saving it?

The correct spell is write-image. Just give it an image and an uri.

I want to change an image's nature.

If you want to, you can. Just look for namespaces under rinzelight.effects. Lookup tables and affine transforms are already available. There are even map-image and map-pixel-location functions. If you want to use map-pixel-location, take a look at rinzelight.effects.helper-functions for a helping hand.

What about a few examples?

I hide them under examples. They are a bit obfuscated using criterium for benchmarking, but they are not hard to understand. For running them, use lein run. They'll take a bit, since I use them as benchmarks.

article clipper Introducing rinzelight 0.0.2
 
share save 171 16 Introducing rinzelight 0.0.2

The One where I spent a morning because -0.5 turned to be parsed as 1/2

September 5th, 2010 Serabe No comments

This summer, I have been doing some amazing stuff for GeoGebra. First of all, I would like to thank two people: Miguel, my mentor, who guided me through all that really advanced mathematical stuff; and Heinz Kredel, JAS creator and developer, who answered all my questions and implemented my suggestions as quickly as I could write them.

This story is about a problem we found in JAS. It was really subtle, so I may need a brief introduction to the project I worked on: LocusEqu. That project retrieves the equation of "any" geometrical locus. If you don't know what a locus is, Wolfram Math World defines it as "the set of all points (usually forming a curve or surface) satisfying some condition" . LocusEqu generates a few EquationExpression, and then, by using a EquationTranslator, it generates a GenPolynomial<BigRational> object.

For translating doubles, it calls the BigRational constructor whose only argument is a String. This is the code:

Can you spot the bug? Look at the 21st line. If s is "-0.5", then n is new BigInteger("-0"), and that's what makes "-0.5" be parsed as 1/2.

article clipper The One where I spent a morning because  0.5 turned to be parsed as 1/2
 
share save 171 16 The One where I spent a morning because  0.5 turned to be parsed as 1/2

Status update for GeoGebra.

July 12th, 2010 Serabe No comments

My contributions for the first part of the first part of GSoC 2010 can be divided in two: general improvements and coding.

General improvements

I made a few general improvements on GeoGebra:

  1. Refactored build.dir in ant build file. Previously, build.dir wasn't in the root directory.
  2. A few ant tasks were added, such compile-grammar, compile-oe (outside Eclipse), run-easyb and run-easyb-outside-eclipse.
  3. SVN properties were set in order to work outside Eclipse. This way, .class files will be kept out of the repo without the intervention of any Eclipse plugin.
  4. Easyb, a BDD groovy-based framework, has been included in order to test GeoGebra. It is not RSpec, but I guess it'll do.

Coding

First, I started creating a few EquationPoint classes,  currently there are six EquationPoint children classes:

Selección 003 Status update for GeoGebra.

  • EquationFreePoint represents an independent point.
  • EquationSymbolicPoint represents a dependent point,  EquationSpecialSymbolicPoint standing only for the locus point.
  • EquationNormalPoint and EquationPointVectorPoint are only auxiliar elements.

Then, a few EquationElement classes were added, these stand for the different constructions:

Selección 001 Status update for GeoGebra.

EquationElement is an abstract class containing a few basic methods:

  • forPoint: Given an EquationPoint, returns a String with the equation that means that the point is in the construction.
  • isAlgebraic: returns true if the construction is algebraic, and false otherwise.

Both EquationGenericCircle and EquationGenericLine are abstractions of specific line and circle contructions, all of them algebraic. EquationGenericSegment is to segment what EquationGenericLine is to lines. Obviously, EquationGenericSegment is not algebraic.

All of these classes are used together by EquationScope.

A pause for a screenshot.

Selección 002 modificada 300x132 Status update for GeoGebra.

Click for enlarge.

A glimpse into the future.

What to do next?:

  • Maybe Equation should be a proper class, not just a String.
  • More equations.
  • Working out the locus equation.
  • Not using an algorithm twice.
article clipper Status update for GeoGebra.
 
share save 171 16 Status update for GeoGebra.

About WordPress automatic upgrade.

June 30th, 2010 Serabe No comments

I'm stupid, and here is why:

Long, long time ago,  when WordPress 2.7 was released I got excited about  the automatic upgrade feature. I never got to get it working, but I didn't care at all. I don't have that many plug-ins, and sometimes in a while, I just uploaded all the files via FTP. But I moved sergio.arbeo.net to WordPress after 3.0 release and then I realize that it was working there!

Then, wondering why, found out this post with its really easy solution: just add the following two lines to the WordPress .htaccess:

# Ensure PHP5 being used

# For WordPress auto upgrade

AddType x-mapp-php5 .php

AddHandler x-mapp-php5 .php

As I said, I'm stupid.

article clipper About WordPress automatic upgrade.
 
share save 171 16 About WordPress automatic upgrade.
Categories: General Tags:

Writing your own JRuby extension. Part II: Creating your first class.

March 12th, 2010 Serabe 1 comment

3783473433 98d837343a m Writing your own JRuby extension. Part II: Creating your first class.
What's the point of coding a JRuby extension if you don't create classes? Well, I cannot think of any case, but if you find one, please, let me know.

Do you remember Java's classes hierarchy? If so, you'll realize  that Java objects inherit from java.lang.Object by default but that is not actually what we need. But how can we tell JRuby that our object inherits from Object, the king of Ruby world? The answer is so simple: just extend RubyObject! (There is a RubyBasicObject too) Taken from Nokogiri::XML::Node:

Of course, you can extend any other class, as long as it is a "Ruby object". For example, Nokogiri::XML::Document extends from Nokogiri::XML::Node, and we do not need to do anything special to reflect it, just extend XmlNode like XmlDocument does:

After talking a bit about hierarchy, let's talk about Java constructors. At least two parameters are needed: a org.jruby.Ruby object and a org.jruby.RubyClass object. Being the importance of the former quite obvious, the reason for the latter may not be so clear. Let me show you some real world code: Nokogiri::XML::Node's dup method. Take a look at the following test:

Both new and dup methods in subclass rely on Nokogiri::XML::Node's. In here, you can see the this snippet of code:

The rb_obj_class method returns the class of an object, in this case, self. This way, the new node will be an instance of the same class as the original node. That's the reason a RubyClass is needed in the constructor, in order to know which is the actual class being instantiated.

By the way, do not forget to call super with the Ruby and RubyClass objects.

Next step: creating methods.

cc Writing your own JRuby extension. Part II: Creating your first class. photo credit: quinn.anya

article clipper Writing your own JRuby extension. Part II: Creating your first class.
 
share save 171 16 Writing your own JRuby extension. Part II: Creating your first class.

Do you wanna help us with pure-Java Nokogiri?

December 1st, 2009 Serabe No comments

First things first, if you wanna help, you'll need to clone the git repo. Just:

git clone git://github.com/tenderlove/nokogiri.git
cd nokogiri
git checkout --track -b java origin/java

Install the dependencies. Just:

rake install:deps

Because it uses some native libraries, you'll need to do that with MRI. Finally, you'll need to generate some files, just run jruby -S rake java:spec. For having a hprof file, you'll need to run this script with the following command:

jr -J-Xmx32m -J-XX:+HeapDumpOnOutOfMemoryError nokogiri_doc_frag.rb

-J-Xmx32m limits the heap space to 32 Mb, and the other options makes the JVM to write a hprof file when a OutOfMemoryError is thrown. After that, you can inspect that file with the profiler you can find in NetBeans.

In next post, I'll comment where I think the problem is.

article clipper Do you wanna help us with pure Java Nokogiri?
 
share save 171 16 Do you wanna help us with pure Java Nokogiri?
Categories: General, Java, JRuby, Programming, Ruby Tags: , ,

Status Update: RMagick4J, Nokogiri, ruby2java and a possible MagickWand4J

June 6th, 2009 Serabe No comments

It's been long time since last status update, but there are some things to tell, so here I am.

Thankfully, this year I'm a GSoC student again (and my mentor is Tom too). The main part of my project would be porting Nokogiri to JRuby, so I haven't code for RMagick for a while now.

Let's start with the status update then.

Nokogiri

I've been working on Nokogiri for a while. I forked Charles' repo in Github, and I've implemented some cool features. For example, today I got my XML::Reader implementation to pass all tests in test_reader.rb. I hope I'll be able to make a release this month (cross your fingers).

On the other hand, I got my first patch accepted in Nokogiri's main repo.

RMagick4J

Not to much work done here, sorry. I haven't code anything for a while now. Migrating from mercurial to git is already planned, but before that I would like to do a few commits more. Anyway, I'm quite happy with this project. Some people are using it and reporting bugs (in the end, those little things are all that matters). What else can I ask for?

Please, if you find a bug, report it here.

MagickWand

Tim Hunter (creator of RMagick) released MagickWand recently. I've been considering porting it to JRuby too. I have to take a deeper look at the C code, but, by now, I think it could be a good way to lead RMagick4J development. If finally I port it, I will split RMagick4J in two projects (Magick4J and RMagick4J). This way, MagickWand4J and RMagick4J would share the same java codebase, as MagickWand and RMagick share ImageMagick.

ruby2java

Take a look here. Awesome, isn't it? And as soon as I have some time to work on it, siesta will be out too...

P.D. By the way, no more personal stuff in this blog. That stuff is now here, and only in Spanish (sorry about that).

article clipper Status Update: RMagick4J, Nokogiri, ruby2java and a possible MagickWand4J
 
share save 171 16 Status Update: RMagick4J, Nokogiri, ruby2java and a possible MagickWand4J

It’s all about expectations.

April 25th, 2009 Serabe No comments

Two days ago, I was talking about Susan Boyle with a friend. I do not like her, my friend didn't even know who she is. I told her about Susan, she has a good voice (not a great one) and she can sing pretty well. The only difference is that she is quite ugly (in Spanish I would say that she is uglier than hitting your own father with a sweaty sock). Her answer was pretty simple: It's all about expectations.

She said that by looking at her, my expectations were low, so when she sang even with a good-but-not-extraordinary-as-they-want-us-to-believe voice.

Other way of making things look better is the Bluetooth-Cooper theorem ("Averything is better with bluetooth"), in this case, with the Jackson-Vader corollary:
0 Its all about expectations.

article clipper Its all about expectations.
 
share save 171 16 Its all about expectations.

RMagick4J: Status Update 15/03/09

March 16th, 2009 Serabe 2 comments

This week I've been fixing some bugs, adding some minor effects and adding wave effect.
In order to add wave effect I've had to read a lot of ImageMagick code. Lucky me, there was an if that made all too much simpler. Unlucky me, I didn't realize until the third reading-code day.
Anyway, after sweating blood, here you are the images:

RMagick RMagick4J
original
jruby RMagick4J: Status Update 15/03/09 jruby RMagick4J: Status Update 15/03/09
charcoal 0.75
charcoalrmi RMagick4J: Status Update 15/03/09 charcoaljruby RMagick4J: Status Update 15/03/09
negate
negatermi RMagick4J: Status Update 15/03/09 negatejruby RMagick4J: Status Update 15/03/09
normalize
normalizermi RMagick4J: Status Update 15/03/09 normalizejruby RMagick4J: Status Update 15/03/09
blur_image 2
blurrmi RMagick4J: Status Update 15/03/09 blurjruby RMagick4J: Status Update 15/03/09
wave
wavermi RMagick4J: Status Update 15/03/09 wavejruby RMagick4J: Status Update 15/03/09
article clipper RMagick4J: Status Update 15/03/09
 
share save 171 16 RMagick4J: Status Update 15/03/09
Categories: General Tags:
Improve the web with Nofollow Reciprocity.