PhiLho tech web log
http://phi.lho.free.fr/serendipity/
Programmer, écrire, dessiner, rêver...frhttp://phi.lho.free.fr/serendipity/templates/default/img/s9y_banner_small.pngRSS: PhiLho tech web log - Programmer, écrire, dessiner, rêver...
http://phi.lho.free.fr/serendipity/
10021Sorting strings by respecting natural order for numbers
http://phi.lho.free.fr/serendipity/index.php?/archives/30-Sorting-strings-by-respecting-natural-order-for-numbers.html
<p>A function that is useful is a <a href="http://docs.oracle.com/javase/6/docs/api/java/util/Comparator.html" title="Java 6 API Reference">comparator</a> of strings (for sorting purpose, in general) that respect the natural order of numbers.
</p>
<p>So when we have a list of strings, like file names, for examples, with numbers in them, it is better to respect the numerical order when strings are equal.</p>
<p>A common case is numbered names: a trivial, lexicographical order would be:<br/>
foo-1<br/>
foo-10<br/>
foo-11<br/>
foo-2<br/>
...<br/>
foo-9<br/>
<br/>
where one expects:<br/>
foo-1<br/>
foo-2<br/>
...<br/>
foo-9<br/>
foo-10<br/>
foo-11<br/>
</p>
<p>I show here how to do such comparator.
</p>
<br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/30-Sorting-strings-by-respecting-natural-order-for-numbers.html#extended">Continuer à lire "Sorting strings by respecting natural order for numbers"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
Java, 2012-10-06T17:27:32Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=302http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=30Gimp 2.6: Copy transparency from one layer/image to another
http://phi.lho.free.fr/serendipity/index.php?/archives/29-Gimp-2.6-Copy-transparency-from-one-layerimage-to-another.html
<p>I had to make a rollover image: a copy of an image with slightly different colors.<br/>
Editing with Gimp 2.6, I just copied the image and altered the colors, but then I adjusted the transparency of the original image (smoother transition from opaque to transparent) and I wanted to copy the transparency information to the rollover image. For some reason, I didn't want to redo the color change again.
</p>
<br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/29-Gimp-2.6-Copy-transparency-from-one-layerimage-to-another.html#extended">Continuer à lire "Gimp 2.6: Copy transparency from one layer/image to another"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
Arts, 2011-05-03T18:32:00Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=291http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=29Is this string a number?
http://phi.lho.free.fr/serendipity/index.php?/archives/28-Is-this-string-a-number.html
<p>A blog post (<a href="http://www.jroller.com/ethdsy/entry/double_parsing_regexp" title="Scratch Where It's Itching">Double Parsing Regexp</a>)
caught my attention. The base problem is to check if a string is a valid number, without necessarily needing the real value.
Or, perhaps, to skip the conversion if we are sure it will fail, as Double.valueOf throws an exception in this case,
and the try/catch mechanism is known to be slow.
</p>
<p>The numbers given were intriguing, and I wondered if the given regular expression could be optimized.
Somehow, it was a great opportunity to use <a href="http://code.google.com/p/caliper/" title="caliper - Project Hosting on Google Code">Caliper</a>
a library to do correctly micro-benchmarks.
</p>
<br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/28-Is-this-string-a-number.html#extended">Continuer à lire "Is this string a number?"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
Java, 2010-12-06T06:21:12Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=280http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=28Building and running Scala programs with Gradle
http://phi.lho.free.fr/serendipity/index.php?/archives/27-Building-and-running-Scala-programs-with-Gradle.html
<p>I recently started to learn Scala, an interesting language in the (very strongly) statically typed category.
So far, I only compiled single files with little or no dependency, so the command line was good enough.
Now, I start to try small sample files with a rather complex classpath (using Piccolo2D and Pivot), so I searched something more sophisticated.
</p>
<p>The main constraint was to be able to compile and run Scala programs, using my local copy of Scala compiler, and the local libraries where I gather them. I soon discovered it is now a quite unusual setup...
</p> <br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/27-Building-and-running-Scala-programs-with-Gradle.html#extended">Continuer à lire "Building and running Scala programs with Gradle"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
Scala, 2010-11-01T16:54:04Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=270http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=27Premiers pas avec Scala
http://phi.lho.free.fr/serendipity/index.php?/archives/26-Premiers-pas-avec-Scala.html
<p>Je me suis enfin mis à Scala ! (depuis deux semaines à peu près)
</p>
<p>Ça faisait un moment que je voulais m'y mettre. J'ai atteint un niveau décent en Java, et je voulais explorer un langage un peu plus souple, n'ayant jamais apprécié les classes anonymes, surcharges de méthodes pour gérer les paramètres optionnels et autres lourdeurs de Java. Sans parler des incohérences hérités du C.
</p>
<p>J'ai balancé un moment entre Groovy et Scala (Clojure : pas fana de Lisp, même si j'ai appris Scheme pour faire des scripts dans Gimp ; JRuby : ressemble trop à Perl ! Jython : pourquoi pas, mais plus tard). J'ai fini par basculer vers Scala !
</p>
<br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/26-Premiers-pas-avec-Scala.html#extended">Continuer à lire "Premiers pas avec Scala"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
Scala, 2010-09-07T14:49:22Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=260http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=26Google Chrome : premières impressions
http://phi.lho.free.fr/serendipity/index.php?/archives/24-Google-Chrome-premieres-impressions.html
<p>Test de Google Chrome 3.0.195.38 le 12 janvier 2010.
</p>
<p>Ça faisait un moment que je voulais l'essayer, au moins en tant que webmaster, vu qu'il faut tester les pages sur un maximum de navigateurs. J'ai attendu qu'il se stabilise, puis j'ai un peu oublié.<br />
Leur publicité (pour un produit gratuit !) sur les murs du RER parisien et en couverture d'un journal gratuit (entre autres) a servi de rappel (donc... c'est efficace). Je soupçonne Google d'avoir demandé aux sites qu'il mentionne dans ses publicités d'aider à financer la campagne...
</p>
<p>Premier contact : désagréable !<br />
J'ai détesté la procédure d'installation... Je peux comprendre la volonté de simplifier la vie de la plupart des utilisateurs, mais cela ne devrait pas exclure un paramétrage fin par ceux qui savent ce qu'ils font...
</p> <br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/24-Google-Chrome-premieres-impressions.html#extended">Continuer à lire "Google Chrome : premières impressions"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)2010-01-21T14:00:31Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=240http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=24JavaFX: 3000 Chars for a Crystal Clock
http://phi.lho.free.fr/serendipity/index.php?/archives/23-JavaFX-3000-Chars-for-a-Crystal-Clock.html
<p>Recently (beginning of this month), Josh Marinacci proposed on the <a href="http://jfxstudio.wordpress.com/">JFXStudio site</a> a <a href="http://jfxstudio.wordpress.com/2009/08/31/jfxstudio-challenge-small-is-the-new-big/" title="JFXStudio Challenge: Small is the New Big">Challenge: Small is the New Big</a>. The goal is to write a short but spectacular JavaFX program on a given theme. The <a href="http://jfxstudio.wordpress.com/2009/09/08/jfxstudio-challenge-theme-revealed/" title="JFXStudio Challenge Theme Revealed">theme was revealed</a> shortly after: Time.
</p>
<br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/23-JavaFX-3000-Chars-for-a-Crystal-Clock.html#extended">Continuer à lire "JavaFX: 3000 Chars for a Crystal Clock"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
JavaFX, 2009-09-30T21:30:00Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=2311http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=23Une loupe en JavaFX
http://phi.lho.free.fr/serendipity/index.php?/archives/22-Une-loupe-en-JavaFX.html
<p>Dans le forum JavaFX de Sun, quelqu'un a demandé <a href="http://forums.sun.com/thread.jspa?threadID=5394690">How to implement magnify glass effect?</a> (Comment implémenter un effet de loupe ?). J'ai trouvé le challenge intéressant, et après quelques fausses pistes et périodes où j'ai fait autre chose, j'ai fini par atteindre un stade utilisable.
</p> <br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/22-Une-loupe-en-JavaFX.html#extended">Continuer à lire "Une loupe en JavaFX"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
JavaFX, 2009-08-30T13:15:00Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=220http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=22A magnifiying glass in JavaFX
http://phi.lho.free.fr/serendipity/index.php?/archives/21-A-magnifiying-glass-in-JavaFX.html
<p>In the Sun JavaFX forum, somebody asked <a href="http://forums.sun.com/thread.jspa?threadID=5394690">How to implement magnify glass effect?</a> I was interested by the challenge, and after some dead end trials and on/off periods of coding, I reached a usable state.
</p>
<br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/21-A-magnifiying-glass-in-JavaFX.html#extended">Continuer à lire "A magnifiying glass in JavaFX"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
JavaFX, 2009-08-30T10:33:00Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=210http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=21Internationalisation des sketchs Processing (et des programmes Java)
http://phi.lho.free.fr/serendipity/index.php?/archives/20-Internationalisation-des-sketchs-Processing-et-des-programmes-Java.html
<p>Suite à une question dans le forum de <a href="http://processing.org/">Processing</a> (<a href="http://processing.org/discourse/yabb2/YaBB.pl?num=1251195029">Localization [ i18n ]</a> - <i lang="en">go there if you can't read French, most of the info here is there</i>), je me suis penché de plus près sur le système d'internationalisation de Java.
</p>
<p>L'internationalisation (i18n en abrégé : 18 lettres entre i et n...) de logiciels est un point important pour une utilisation aisée dans tous les pays. Cela comprend non seulement la traduction des textes, mais aussi la prise en compte des particularités de chaque pays (localisation, ou l10n), comme les séparateurs de décimales et de milliers, l'écriture des dates, la gestion des pluriels, etc.
</p>
<p>Je me suis aperçu que pour Processing, il fallait contourner certains obstacles pour parvenir au résultat. Je livre ici mon expérience, dont une partie est utilisable directement dans Java.
</p> <br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/20-Internationalisation-des-sketchs-Processing-et-des-programmes-Java.html#extended">Continuer à lire "Internationalisation des sketchs Processing (et des programmes Java)"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
Processing, 2009-08-28T21:55:43Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=200http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=20Attention au système de déduction de type de JavaFX !
http://phi.lho.free.fr/serendipity/index.php?/archives/19-Attention-au-systeme-de-deduction-de-type-de-JavaFX-!.html
<p>Certains raccourcis de codage offerts par JavaFX, qui sont sympas quand ils sont pris séparément, peuvent constituer une combinaison mortelle quand ils sont utilisés ensemble...
</p>
<br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/19-Attention-au-systeme-de-deduction-de-type-de-JavaFX-!.html#extended">Continuer à lire "Attention au système de déduction de type de JavaFX !"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
JavaFX, 2009-06-20T09:33:02Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=190http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=19Beware of JavaFX's type inference!
http://phi.lho.free.fr/serendipity/index.php?/archives/18-Beware-of-JavaFXs-type-inference!.html
<p>Some programming shortcuts offered by JavaFX, nice when taken separately, can be a deadly combination when used together...
</p>
<br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/18-Beware-of-JavaFXs-type-inference!.html#extended">Continuer à lire "Beware of JavaFX's type inference!"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
JavaFX, 2009-06-20T07:39:38Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=182http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=18JavaFX 1.2 est sorti !
http://phi.lho.free.fr/serendipity/index.php?/archives/17-JavaFX-1.2-est-sorti-!.html
<p>La nouvelle version de JavaFX vient de sortir, comme prévu à temps pour JavaOne, et je dois avouer qu'elle restaure quelque peu la confiance érodée ces derniers temps que j'avais en cette plateforme.
Je n'ai plus l'impression d'avoir perdu mon temps à apprendre et tester ce langage et cette API !
</p> <br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/17-JavaFX-1.2-est-sorti-!.html#extended">Continuer à lire "JavaFX 1.2 est sorti !"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)2009-06-02T21:39:45Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=170http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=17Déformations par déplacement des pixels en JavaFX
http://phi.lho.free.fr/serendipity/index.php?/archives/16-Deformations-par-deplacement-des-pixels-en-JavaFX.html
<p>Encore une applet JavaFX pour répondre dans les forums Sun: <a href="http://forums.sun.com/thread.jspa?threadID=5376058">Effect FloatMap</a> (<i lang="en">see this thread if you don't read French!</i>). J'aime bien ces questions me permettant d'explorer quelques coins méconnus (par moi) de l'API.
</p>
<p>Ici, il s'agissait d'une question sur FloatMap, m'amenant à m'intéresser à DisplacementMap.
</p>
<br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/16-Deformations-par-deplacement-des-pixels-en-JavaFX.html#extended">Continuer à lire "Déformations par déplacement des pixels en JavaFX"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
JavaFX, 2009-04-03T21:28:35Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=160http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=16Affichage des couleurs pré-définies en JavaFX
http://phi.lho.free.fr/serendipity/index.php?/archives/15-Affichage-des-couleurs-pre-definies-en-JavaFX.html
<p>Une question dans les forums Sun (<a href="http://forums.sun.com/thread.jspa?threadID=5357341">Color chart reference</a> - <i lang="en">see this thread if you don't read French!</i>) m'a motivé pour écrire un programme non trivial en JavaFX, affichant les couleurs pré-définies (statiques) de JavaFX avec leur noms. Rien de très gros, mais c'est ma première utilisation de la réflexion dans ce langage, et un rare (à ce jour) exemple d'utilisation de cette réflexion (en dehors de l'intégration à Java).
</p> <br /><a href="http://phi.lho.free.fr/serendipity/index.php?/archives/15-Affichage-des-couleurs-pre-definies-en-JavaFX.html#extended">Continuer à lire "Affichage des couleurs pré-définies en JavaFX"</a>
PhiLho tech web lognospam@example.com (Philippe Lhoste)
JavaFX, 2009-03-19T19:04:21Zhttp://phi.lho.free.fr/serendipity/wfwcomment.php?cid=151http://phi.lho.free.fr/serendipity/rss.php?version=1.0&type=comments&cid=15