Archive

Author Archive

Adding organization repos to Travis-CI: Part I

October 9th, 2011 Serabe No comments

It was a nice FridayPorras and I were at the BeBanjOffice and  we were working on adding organization support to Travis-CI.

First, we needed to find where the user repos were being fetch. Said and done, we found that travis is using the ServiceHookController to ask the server for repos (and to update them too, but don’t hurry, we’ll get there in part II). The controller was using the github_repositories method in the User model. Finally, we arrived to Travis::GithubApi, where all our questions found answers.

repositories_for_user just relied on Octokit#repositories for getting the repos, so we added all the code after the plus sign. You might think that this code lacks the proper security, is wrong and that it shouldn’t be there (and damn it, you’re right!) but there is no easy way to retrieve only the repos where the user has admin privileges (we wasted hours on this and a quick message to Github confirmed it).  Basically, it asks for all organizations for the given user (beware! You need to make your membership public, otherwise it won’t work) and then flat_map them to the repos in the given organization (whether the user can administrate them or not).

Later, the each block was added so we could know whether the repo belongs to the user or to an organization.

Stop! Hammertime!

We needed a way to let the user know that a repo actually belongs to an organization, so we added that info to the template (that {{#if content.organization_name}} is ours icon biggrin Adding organization repos to Travis CI: Part I ) and added some style so it could look this awesome:

20110928 q5hyhyuddmqnsr7awgmxtj6ph5.medium Adding organization repos to Travis CI: Part I

We had some tough time trying to get it vertically centered, but after realizing that Github has its tags the same way as we do, we stop trying to fix it. And they still look awesome.

More coming in part II.

article clipper Adding organization repos to Travis CI: Part I
 
share save 171 16 Adding organization repos to Travis CI: Part I

Transforming CSS selector to an XPath query

September 9th, 2011 Serabe No comments

So. Easy.

RUBY:
  1. require 'nokogiri'; Nokogiri::CSS.xpath_for(css_selector)

article clipper Transforming CSS selector to an XPath query
 
share save 171 16 Transforming CSS selector to an XPath query
Categories: Programming, Ruby Tags: , ,

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:

The Essential Guide to HTML5: a review

January 2nd, 2011 Serabe No comments

After reading this book I have some encountered feelings about it: on the one hand the content is correct, everything I tested worked fine, etc but on the other hand I really find annoying the form it is presented.

When I started reading, I expected to find more about CSS3 (a topic almost not covered in the book) and less Javascript, but since this is only an expectation, I'll try my best so it doesn't affect this review.

Since I wrote before, the content is correct. Covers a huge part of the new apis, the examples usedare not too complex yet interesting and it is not hard to follow. Without any doubt, the form code snippets are displayed. The code is displayed in a two-column table (one for code, one for comments) and each line (each line!) is commented. Seriously, I've seen the <html> line commented!

And even if the content is good, the table issue makes it really hard to read if you are a medium-experienced programmer. These are my encountered feelings: good content, not that good layout.

article clipper The Essential Guide to HTML5: a review
 
share save 171 16 The Essential Guide to HTML5: a review
Categories: Books, Programming Tags:

Creating a blur effect with rinzelight.

October 31st, 2010 Serabe No comments

After releasing rinzelight 0.0.3, I wondered how hard addinga blur effect would be. So I started implementing it.

We are going to do two 1D blur. In first place, open a repl and start emacs (or vim). Use rinzelight.image for reading northern-lights.jpg

First, let's start creating a blur-kernel function with two parameters, width and sigma. Rinzelight lacks of a kernel-rank constant, so let's add it. Open src/rinzelight/constants and add the following line to the end:

We get a horizontal kernel, which we will apply twice, one horizontally and one vertically. For getting a vertical kernel, we write one final function called transpose-horizontal-kernel:

And now, we are ready to write the blur effect:

And this is the result of a (blur (read-image "samples/northern-lights.jpg") 5 1.5 repeat-op rendering-quality):

example blur Creating a blur effect with rinzelight.

(blur img 5 1.5 repeat-op rendering-quality)

And that's it!

article clipper Creating a blur effect with rinzelight.
 
share save 171 16 Creating a blur effect with rinzelight.
Categories: Clojure, Programming 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:

Simple mathematical concepts I: Induction.

March 29th, 2010 Serabe No comments

4458595395 2c1bbc10e5 m Simple mathematical concepts I: Induction.
After reading this and this I realized something is really, really wrong about mathematical concepts out there. Proof by induction is a really, really simple yet powerful proof method.  In this post, I will talk about induction for natural numbers.

Induction is based on two steps, usually called basis and inductive step. I will proof that 1+2+...+n=n(n+1)/2  for all natural numbers using induction.

  1. Basis or base case consists on proving the predicate for an initial value, usually a small one. In the example 1=1*2/2=1.
  2. Inductive step consists on supposing the if the predicate holds for n, then it also holds for n+1. In the example:

1+2+...+n+(n+1)=(n+1)+n(n+1)/2 because we supposed that predicate held for n. We need to prove that this expression is equivalent to (n+1)(n+2)/2. Indeed,

(n+1)+n(n+1)/2=(n+1)(1+n/2)=(n+1)((2+n)/2)=(n+1)(2+n)/2

so the predicate has been proofed for all natural numbers.

Why does induction work?

Think of any natural number, as big as you want. Got it? We know that the predicate holds for 1, and that if the predicate holds for a number it holds for its successor. So it holds for 2, and for 3 and so on until it reach your number.

Other types of induction.

There are several types of inductions. Two of these types are structural induction and complete induction.

cc Simple mathematical concepts I: Induction. photo credit: hartboy

article clipper Simple mathematical concepts I: Induction.
 
share save 171 16 Simple mathematical concepts I: Induction.
Improve the web with Nofollow Reciprocity.