Adding organization repos to Travis-CI: Part I
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 ) and added some style so it could look this awesome:
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.
Transforming CSS selector to an XPath query
So. Easy.
-
require 'nokogiri'; Nokogiri::CSS.xpath_for(css_selector)
Tries: la pronunciación se deja como ejercicio para el lector.
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)
The Essential Guide to HTML5: a review
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.
Creating a blur effect with rinzelight.
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)
:
(blur img 5 1.5 repeat-op rendering-quality)
And that's it!
Introducing rinzelight 0.0.2
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.
The One where I spent a morning because -0.5 turned to be parsed as 1/2
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.
Status update for GeoGebra.
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:
- Refactored build.dir in ant build file. Previously, build.dir wasn't in the root directory.
- A few ant tasks were added, such compile-grammar, compile-oe (outside Eclipse), run-easyb and run-easyb-outside-eclipse.
- 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.
- 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: