Saturday, December 06, 2008

a simple script to install remotely plugins and theme to wordpress

when I want to install a plugin or a theme on my distant server, I merely copy the URL in the clipboard and type in the terminal of my macbook
>plugin www.../
To do this, just add to your .bashrc :
plugin () { ssh "cd /var/www/; wget -O toto $1; unzip toto; rm toto" } theme () { ssh "cd /var/www/; wget -O toto $1; unzip toto; rm toto" }

Sunday, August 10, 2008

unix pipe at work

I wanted to copy a large amount of files into my iTunes library.
Bummer, a computer got disconnected right in the middle, after 5 hours of copy...
how do I resume where it stopped ?
I saw that every directory u until letter D was already copied.
After a few tinkering, I finally found how to not repeat the copy already made :
find . -maxdepth 1 |  | grep '^..[C-Z]+*' | tr '\012' '\000' | xargs -0 -Ifrom cp -Rvf from /bibliotheque/music
There you go
edit : added the | tr '\012' '\000' | xargs -0 step that permits to circumvent the old misunderstanding between \n and null terminated entries

Saturday, September 22, 2007

Fuse rocks

FUSE enables you to mount a remote filesystem locally. It is common knowledge that computers are done for lazy people to spend 2 hours to find a way to save 5 minutes. I therefore mount my dedibox to ~/dediboxfs and, magic, I can publish and access all the remote files as if they were just there. For macs it's a gift from google, to be found there for MacFuse , and there for SSHFS, other FS are available elsewhere (ftp, gmail, etc... )

Sunday, June 17, 2007

dedibox and awstats

My dedibox kept crashing because of awstats apparently. Every 2 or 3 days, I needed to reboot it electrically. I advise you to deactivate this module in the cron jobs, unless you have time to deal with it. On another subject, I posted a nice video from Google on xQuant that talks about a practical use of inference to unsupervisely discover structure among texts.

Saturday, June 09, 2007

Blogs et dépendances

If I look at my subscription habits, I mostly subscribe to blog that are either
  • Very specialized on a technical subject
  • At a forking point on a topical and applicative subject
That is why I prefer to split my blogs between
  • my technical geeky posts about Linux, MacOs, and other system-oriented issues on Technofinance
  • my math and theoretical posts on xQuant, which intends to be more of an applicative forking point
I would be interested to know better about the way readership actually perceives and structures its reading...

Sunday, June 03, 2007

Wikimedia, Ruby, php, plesk, Apache all working together and being friendly to each other

In a brilliant demonstration of technical expertise and non-conformist brio, that is, of utter elegance, xQuant is now equipped with a Wiki section that will enable users to render their thoughts in plain English and Latex.

This Wiki is particularly meant to be used to develop themes including inference, categories, and stochastic finance.

Saturday, May 12, 2007

A probability problem and some Ruby

A thoroughly honest game-show host has placed a car behind one of three doors. There is a goat behind each of the other doors. You have no prior knowledge that allows you to distinguish among the doors. "First you point toward a door," he says. "Then I'll open one of the other doors to reveal a goat. After I've shown you the goat, you make your final choice whether to stick with your initial choice of doors, or to switch to the remaining door. You win whatever is behind the door." You begin by pointing to door number 1. The host shows you that door number 3 has a goat.

Do the player's chances of getting the car increase by switching to Door 2?

The answer is yes. There are different ways of looking at the pb. One is to go on with computation after having a clear view of what to compute. In situations like this, you need to deal with the information given to you, namely the door opened for you. Then one has to always pick the door with the highest probability conditioned to all the information given. In this case, we just know the result of some operation the host did. This is typically where to use the Bayes theorem, as it enables us to revert the conditioning to a probability we know, since we know the process followed to pick the opened door. So if we compute the probability of each possibility we have : c1, c2, c3 denote that the corresponding door has a car behind o2 denotes the fact that the door 2 has been opened p1 denotes the fact that you picked the door 1 in the first place
  • P (c1 | o2, p1) = P ( o2 | c1, p1) * P(c1 | p1 ) / P(o2 | p1 ) = 1/2 * 1/3 / 1/2 = 1/3
  • P (c2 | o2, p1) = P ( o2 | c2, p1) * P(c2 | p1 ) / P(o2 | p1 ) = 0 * 1/3 / 1/2 = 0
  • P (c3 | o2, p1) = P ( o2 | c3, p1) * P(c3 | p1 ) / P(o2 | p1 ) = 1 * 1/3 / 1/2 = 2/3
The first equality is just Bayes theorem. then if we explain in plain english the results :
  • P ( o2 | c1, p1) = 1/2 because if p1 happens, the host will have to pick between door 2 and door 3 to open, and since the car is behind door 1, he has no other constraints. chance are therefore 1/2 he'll pick up door 2.
  • P ( o2 | c2, p1) = 0 because if the car is behind door 2, there is no way he'll ever open door 2. Also, P ( c2 | o2 ) = 0 so that P (c2 | o2, p1) = 0 too so we don't even have to compute this.
  • P ( o3 | c2, p1) = 1 because if p1 happens, the host will have to pick between door 2 and door 3, but the car being behind door 2, he'll have no choice but to pick the door 3
So we see through Bayes that we have an incentive to switch the door we choosed. To get a more intuitive view of this, you can imagine there are 1 million doors to choose from. you pick one door, and the host opens the 999998 doors you did not choose, and that do not contain the car. what are the chance your pick was good in the first place ? it's far more likely the remaining door you did not choose has the car. A different approach is through raw computation. A clever Rubyist, Daniel Martin, posted a nice illustration to this.
puts('===Monty Hall, classic version===')
ProbabilityTree.runreport(1.to_r) { |u|
treasuredoor = u.choose(1,2,3)
guessdoor = u.choose(1,2,3)
remaining_doors = [1,2,3].select{ |x|
   x != treasuredoor and x != guessdoor }
showdoor = u.choose(*remaining_doors)
if (treasuredoor == guessdoor) "You should stay"
else "You should switch"

===Monty Hall, classic version===
You should switch
==>     2/3
You should stay
==>     1/3
This piece of code illustrates the flexibility of lambda function, as it enables to completely dissociate a particuliar drawing (you win, you loose) to the context in which it is used ( here, it is used to draw up a certain number of simulations, and accumulate the results to see which is more likely)

Monday, April 30, 2007

Real real estate market

Sunday, April 08, 2007


Those wanting to learn Ruby and increase their ruby-fu would find an great help in a gem called facets. Written by the most prominent rubycists it cristalizes (sic) the best of ruby. Apart from being a useful library, its code is a delight to study. the usual command applies here : sudo gem install facets

Wednesday, March 21, 2007

Rails and spoonerism :

In those days of heavy political election in what's left of France, let us celebrate the lightness and purity of Ruby programming langage. What else could such a nice and sleek website for spoonerism like be propelled with ? Let's not understate the immense contribution that Ruby and rails provided to the fine art of spoonerism. Such a spirited art could only be moved by a langage equally elevated among the most elitist minds. So for all spooners and jolly puners, when the pun is slow to come, here is a lightspeed fastway to come up with a pun. I must mention for the sake of completeness that each pun has been professionnaly tested, in compliance with the last and most advanced methodology of web application design. Yours truly, Nicolas