Pages

Thursday, November 17, 2011

Contribution to the Book of Knowledge

The old version of Wikipedia. Yes, this is a joke. 
 
   I just made my first contribution to Wikipedia. Considering that it is the first place when I need to check something quickly, or to get references for specific subjects since it launched (yes, I was 11 years old at the time), it was about time I made a contribution!

   Go ahead, do the same! You'll feel better! 
Support Wikipedia

Thursday, August 18, 2011

How-to make LaTeX footnotes stick to the bottom of the page

   Disclaimer. The credit goes all to Nikos Skalkotos, on whose blog I found this. I couldn't help but repost it here.

    Sometimes, when you write something in LaTeX which has a number of figures, some pages have a lot of whitespace. If you also have a footnote on this page, the footnote won't be typeset at the bottom of the page, but directly below the text .

    I find this utterly annoying. So, after a little Googling, I found the package footmisc. It can be used to typeset the footnotes at the bottom of the page, even if there's a boatload of whitespace before. Just use the following command in the preamble:
\usepackage[bottom]{footmisc}

and tada! 

    Happy TeXing!


Return user-defined sets in PostgreSQL


   Returning sets of data with PL/pgSQL functions can be somewhat tricky. The documentation has a line saying how to do it somewhere, but the beginner SQL user (like the author of this post) might be confused at the impressive amount of information given by this document.

   This post is thus intended as an example that firsts creates a small database and a function that manipulates data. Let's do this!

First, let's create two tables with some data in them.
CREATE TABLE foo (
"IndexFoo" integer DEFAULT nextval('"sq_IndexFoo"'::regclass) NOT NULL,
"FOO_IndexCol1" integer NOT NULL,
"FOO_Timestamp" timestamp without time zone DEFAULT now()
);

And a table that is pointed to by foo:
CREATE TABLE foo_info (
"IndexInfoFoo" integer DEFAULT nextval('"sq_IndexFooInfo"'::regclass) NOT NULL,
"INF_Answer" integer DEFAULT 42
); 
Now say we want to return rows from both tables. Say we want the answer, given in foo_info and the timestamp, given in foo. We just have to create a function that does just
CREATE OR REPLACE FUNCTION "f_whatIsTheAnswer"(OUT answer integer, OUT "time" timestamp without time zone)

RETURNS SETOF record AS $$

BEGIN


RETURN QUERY SELECT fi."INF_Answer", f."FOO_Timestamp"
FROM foo f

JOIN "foo_info" fi ON f."FOO_IndexCol1" = fi."IndexInfoFoo";
END;
$$ LANGUAGE plpgsql;
Notice how the returned columns are defined in the function's arguments. This defines the column set returned by the function. If left out, PostgreSQL will complain that the record type has not been assigned any return type.

Because we use PL/pgSQL, the RETURN QUERY statement is used. Since this is a simple query with no complex data manipulation, it could have been a simple SQL request. The RETURN QUERY would have been unnecessary.

Try it yourself! Here's the database dump.

Wednesday, August 10, 2011

Removing files from working directory not under version control

   I've been using SVN since the beginning of summer and I'm liking it so far. However, I stumbled across a little problem this week.

    I use SVN to write a LaTeX document which spans multiple files. Being textual, the contents of the .tex files are diff-able and all the features of SVN can be used. However, when I compile the document to have a nice PDF file, a plethora of files are simultaneously created. I don't want to put these files under version control. I hear you say: "Well, do not add them to your repository, then!". Fair enough, here's the result of a svn st:
Cluttered up svn st. I hate cluttered 
I hate cluttered things! Now, the easy solution is to remove all files you do want to put under version control, marked by a '?'. You always the manual way, i.e. rm file1 file2 file3 ... fileX but that's cumbersome. Let's use some of our bash knowledge to solve this problem. 

WARNING. The following command will remove all files marked with a '?'. Be careful with it!

rm `svn st | grep ?`

Simple enough, huh? 

Saturday, June 25, 2011

Programming is fun!

A look at my coding environment
   I've started programming about a month ago. I pretty much learned by myself by reading a book or two about C++. Oh, and I skimmed some parts of C++ GUI Programming with Qt 4, by Jasmin Blanchette and Mark Summerfield. So far, I'm liking it.

   I use the Qt Creator IDE, which provides graphical tools to edit UI files and pretty much helps at every level of application development.

   In short, I'm doing an interface to a PostgreSQL database. I may post screenshots of it when I'm at a more advanced stage. For now, the interface does not do a lot of things.


Tuesday, June 21, 2011

IBM turns 100!



    IBM has just turned 100. To celebrate this stellar achievement, the company has produced a video that summarizes its century of existence in a rather poignant way. 
Enjoy!

[Video LinkIBM Centennial Film
   

Friday, June 17, 2011

Integrability and Chaos in Hamiltonian Systems

   This last semester, I took a course intitled Nonlinear Dynamics and Chaos (in  French). It was quite a novelty, as undergraduates in physics mostly deal with linear problems (they are much easier to solve analytically. Most nonlinear systems do not possess such solutions and they do, the analytic expression is so complex that it offers no qualitative understanding of the subject.

    A dynamicist must make use of a completely different set of tools, mostly numeric, to try to grasp the inner workings of a particular system. Phase space, which shows the relationship between a variable and its nth order derivatives (where n is the dynamical order of the system, if I can use this vocabulary), is an important example of these tools.

   In the special context of Hamiltonian mechanics, where momenta and position are related through what is called a symplectic symmetry, the topology of the phase space trajectories are significantly restricted; they are N-tori. That is, as long as the system is integrable (has a closed form solution).

   As soon as a perturbation is added that renders the system non-integrable, then the phase space qualitatively evolves as described by what is called the KAM Theorem.

This last theorem was the main topic of a mini research project that was conducted by Raphaël Dubé-Demers and myself throughout the second half of the semester. Following these last few words are the text produced during this research and the Beamer presentation used to introduce the subject to our peers.

Happy reading!

[Presentation]  (in French)
[Text]  (in French)

To anyone that will ask nicely, I could translate it in English. Asked very nicely!

UPDATE: I made a flipbook out of it. It looks pretty cool, but that's pretty much it!
UPDATE 2: Here's the link to the complete thing.