Adding organization repos to Travis-CI: Part I

October 9th, 2011 Serabe No comments

It was a nice Friday, Porras 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 spacer ) and added some style so it could look this awesome:

spacer

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.

spacer
 
spacer
Categories: Programming, Ruby, Ruby on Rails Tags: opensource, Ruby, sproutcore, travis-ci

Transforming CSS selector to an XPath query

September 9th, 2011 Serabe No comments

So. Easy.

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

spacer
 
spacer
Categories: Programming, Ruby Tags: nokogiri, programming, Ruby

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 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)

 

spacer
 
spacer
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.

spacer
 
spacer
Categories: Books, Programming Tags: book

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):

spacer

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

And that's it!

spacer
 
spacer
Categories: Clojure, Programming Tags: clojure, rinzelight

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.

spacer
 
spacer
Categories: Clojure, General, Programming Tags: clojure, rinzelight

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.

spacer
 
spacer
Categories: General, GeoGebra, Java, Programming Tags: bug, geogebra, jas, Java, programming

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:

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.