<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:content="http://purl.org/rss/1.0/modules/content/">
   <channel>
       <title>quickies.seriot.ch</title>
       <description>Références rapides de programmation Mac OS X</description>
       <link>http://quickies.seriot.ch</link>

       <language>en-gb</language>
       <image>
           <url>http://quickies.seriot.ch/images/logo.gif</url>
           <title>Logo title</title>
           <link>http://quickies.seriot.ch</link>
           <description>logo description</description>
       </image>
       <item>
                       <title>Accolade conditionnelle</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=3#a1</link>
                       <description>

En mode mathématique.

m(i) = \left\{
    \begin{array}{ll}
        c_{si} &amp; \mbox{si } \{s,i\} \in E \\
        \infty &amp; \mbox{sinon}
    \end{array}
\right.


Exactement la même chose, mais avec le paquetage amsmath :

m(i) = \begin{cases}
       c_{si} &amp; \text{si } \{s,i\} \in E \\
       \infty &amp; \text{sinon}
       \end{cases}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/accolades/accolade_conditionnelle.png" alt="Accolade conditionnelle" title="Accolade conditionnelle" /></p>

<p>En mode mathématique.</p>

<pre><code>m(i) = \left\{
    \begin{array}{ll}
        c_{si} &amp; \mbox{si } \{s,i\} \in E \\
        \infty &amp; \mbox{sinon}
    \end{array}
\right.
</code></pre>

<p>Exactement la même chose, mais avec le paquetage amsmath :</p>

<pre><code>m(i) = \begin{cases}
       c_{si} &amp; \text{si } \{s,i\} \in E \\
       \infty &amp; \text{sinon}
       \end{cases}
</code></pre>
]]></content:encoded>
                       <category>Accolades</category>
                       </item><item>
                       <title>Accolades horizontales</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=3#a2</link>
                       <description>

En mode mathématique.

n \cdot
\underbrace{\ln \left( \frac{35}{36} \right)}_{\mbox{\footnotesize{toujours }}&lt; 0}
&lt; \overbrace{\ln \left(\frac{1}{2} \right)}^{\simeq -0.693}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/accolades/accolades_horizontales.png" alt="Accolades horizontales" title="Accolades horizontales" /></p>

<p>En mode mathématique.</p>

<pre><code>n \cdot
\underbrace{\ln \left( \frac{35}{36} \right)}_{\mbox{\footnotesize{toujours }}&lt; 0}
&lt; \overbrace{\ln \left(\frac{1}{2} \right)}^{\simeq -0.693}
</code></pre>
]]></content:encoded>
                       <category>Accolades</category>
                       </item><item>
                       <title>Afficher les réseaux sans fil</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=29#a105</link>
                       <description>$ /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -S

Voir le manuel : airport --help
</description>
                       <content:encoded><![CDATA[<p><code>$ /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -S</code></p>

<p>Voir le manuel : <code>airport --help</code></p>
]]></content:encoded>
                       <category>Airport</category>
                       </item><item>
                       <title>Redémarrer le serveur proprement</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=35#a119</link>
                       <description>$ sudo apachectl graceful

</description>
                       <content:encoded><![CDATA[<pre><code>$ sudo apachectl graceful
</code></pre>
]]></content:encoded>
                       <category>Apache</category>
                       </item><item>
                       <title>Pinguer un périphérique AppleTalk</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=50#a222</link>
                       <description>$ appleping "HP LaserJet 2200:LaserJet 2200"

</description>
                       <content:encoded><![CDATA[<pre><code>$ appleping "HP LaserJet 2200:LaserJet 2200"
</code></pre>
]]></content:encoded>
                       <category>AppleTalk</category>
                       </item><item>
                       <title>Un browser AppleTalk en ligne de commande</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=50#a224</link>
                       <description>$ atlookup

Found 5 entries in zone My-Zone
6b5b.c3.ea 3-Eyed Monster:LaserWriter
6b5b.80.fd 3-Eyed Monster Spooler:LaserWriter
6b14.84.ea Incognito :LaserWriter
6b19.a3.fd Light of Day:AFPServer
6b51.27.fd Nets-R-Us Spooler:LaserWriter

</description>
                       <content:encoded><![CDATA[<pre><code>$ atlookup

Found 5 entries in zone My-Zone
6b5b.c3.ea 3-Eyed Monster:LaserWriter
6b5b.80.fd 3-Eyed Monster Spooler:LaserWriter
6b14.84.ea Incognito :LaserWriter
6b19.a3.fd Light of Day:AFPServer
6b51.27.fd Nets-R-Us Spooler:LaserWriter
</code></pre>
]]></content:encoded>
                       <category>AppleTalk</category>
                       </item><item>
                       <title>Voir l'état des périphériques AppleTalk</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=50#a223</link>
                       <description>$ atstatus "HP LaserJet 2200:LaserJet 2200"

</description>
                       <content:encoded><![CDATA[<pre><code>$ atstatus "HP LaserJet 2200:LaserJet 2200"
</code></pre>
]]></content:encoded>
                       <category>AppleTalk</category>
                       </item><item>
                       <title>Arbre 1</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=5#a10</link>
                       <description>

Avec le paquetage pst-tree.

\pstree{\Tcircle{A}}
       {\pstree{\Tcircle{B}}
               {\Tcircle{D}
                \Tcircle{E}}
        \pstree{\Tcircle{C}}
               {\Tcircle{F}
                \Tcircle{G}}}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/arbres/arbre.png" alt="Arbre" title="Arbre" /></p>

<p>Avec le paquetage pst-tree.</p>

<pre><code>\pstree{\Tcircle{A}}
       {\pstree{\Tcircle{B}}
               {\Tcircle{D}
                \Tcircle{E}}
        \pstree{\Tcircle{C}}
               {\Tcircle{F}
                \Tcircle{G}}}
</code></pre>
]]></content:encoded>
                       <category>Arbres</category>
                       </item><item>
                       <title>Arbre 2</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=5#a11</link>
                       <description>

Avec le paquetage pst-all (pas besoin de charger color).

\definecolor{macouleur}{rgb}{0.75, 0.75, 1.0}


...

\newcommand{\B}[1]{\Tr{\psframebox{#1}}} % boite
\newcommand{\C}[1]{\Tcircle{#1}}         % cercle
\newcommand{\N}[1]{\Tr{#1}}              % normal
%\newcommand{\T}[1]{\Ttri{#1}}           % triangle
% triangle qui s'accroche par le haut (sous-arbres...)
\newcommand{\T}[2][]{\Tr[ref=t]{\pstribox[#1]{#2}}}
% cercle coloré
\newcommand{\CC}[1]{\Tcircle[fillstyle=solid,fillcolor=macouleur]{#1}}

% syntaxe : \pstree{le père}{les fils}
\pstree{\C{titi}}
    {
        \B{toto}
        \pstree[levelsep=1cm]{\CC{tata}}
            {
                \B{tutu}
                \N{pipo}
                \T{tonton}
            }
    }

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/arbres/arbre_2.png" alt="Arbre" title="Arbre" /></p>

<p>Avec le paquetage pst-all (pas besoin de charger color).</p>

<pre><code>\definecolor{macouleur}{rgb}{0.75, 0.75, 1.0}
</code></pre>

<p>...</p>

<pre><code>\newcommand{\B}[1]{\Tr{\psframebox{#1}}} % boite
\newcommand{\C}[1]{\Tcircle{#1}}         % cercle
\newcommand{\N}[1]{\Tr{#1}}              % normal
%\newcommand{\T}[1]{\Ttri{#1}}           % triangle
% triangle qui s'accroche par le haut (sous-arbres...)
\newcommand{\T}[2][]{\Tr[ref=t]{\pstribox[#1]{#2}}}
% cercle coloré
\newcommand{\CC}[1]{\Tcircle[fillstyle=solid,fillcolor=macouleur]{#1}}

% syntaxe : \pstree{le père}{les fils}
\pstree{\C{titi}}
    {
        \B{toto}
        \pstree[levelsep=1cm]{\CC{tata}}
            {
                \B{tutu}
                \N{pipo}
                \T{tonton}
            }
    }
</code></pre>
]]></content:encoded>
                       <category>Arbres</category>
                       </item><item>
                       <title>Arbre 3</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=5#a12</link>
                       <description>

Avec le paquetage pst-tree.

\newcommand{\C}[1]{\Tr{\psframebox{#1}}} % carré
\newcommand{\R}[1]{\Tcircle{#1}}         % rond
\newcommand{\N}[1]{\Tr{#1}}              % normal
% syntaxe : \pstree{le père}{les fils}
\pstree[treemode=R]{\R{titi}}
    {
        \C{toto}
        \pstree{\R{tata}}
            {
                \C{tutu}
                \R{345}
                \N{tonton}
            }
    }

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/arbres/arbre_3.png" alt="Arbre" title="Arbre" /></p>

<p>Avec le paquetage pst-tree.</p>

<pre><code>\newcommand{\C}[1]{\Tr{\psframebox{#1}}} % carré
\newcommand{\R}[1]{\Tcircle{#1}}         % rond
\newcommand{\N}[1]{\Tr{#1}}              % normal
% syntaxe : \pstree{le père}{les fils}
\pstree[treemode=R]{\R{titi}}
    {
        \C{toto}
        \pstree{\R{tata}}
            {
                \C{tutu}
                \R{345}
                \N{tonton}
            }
    }
</code></pre>
]]></content:encoded>
                       <category>Arbres</category>
                       </item><item>
                       <title>Arbre binaire coloré pondéré</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=5#a13</link>
                       <description>

Avec les paquetage pst-tree.

\newcommand{\N}{\Tcircle[fillstyle=solid,fillcolor=black]{ }}
\newcommand{\B}{\Tcircle[fillstyle=solid,fillcolor=white]{ }}

\pstree[treemode=R]{\Tr{}}
       {
            \pstree{\B^{3/5}}
            {
                \pstree{\B^{2/4}}
                {
                    \pstree{\B^{1/3}}
                    {
                        \N_{2/2}
                    }
                    \N_{2/3}
                }
                \N_{2/4}
            }
            \N_{2/5}}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/arbres/arbre_binaire_colore_pondere.png" alt="Arbre" title="Arbre" /></p>

<p>Avec les paquetage pst-tree.</p>

<pre><code>\newcommand{\N}{\Tcircle[fillstyle=solid,fillcolor=black]{ }}
\newcommand{\B}{\Tcircle[fillstyle=solid,fillcolor=white]{ }}

\pstree[treemode=R]{\Tr{}}
       {
            \pstree{\B^{3/5}}
            {
                \pstree{\B^{2/4}}
                {
                    \pstree{\B^{1/3}}
                    {
                        \N_{2/2}
                    }
                    \N_{2/3}
                }
                \N_{2/4}
            }
            \N_{2/5}}
</code></pre>
]]></content:encoded>
                       <category>Arbres</category>
                       </item><item>
                       <title>Permissions</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=22#a70</link>
                       <description>. R W X
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1 

</description>
                       <content:encoded><![CDATA[<pre><code>. R W X
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1 
</code></pre>
]]></content:encoded>
                       <category>chmod</category>
                       </item><item>
                       <title>Afficher / masquer la flèche de la souris</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a226</link>
                       <description>[NSCursor hide];
[NSCursor unhide];
[NSCursor setHiddenUntilMouseMoves:YES];

</description>
                       <content:encoded><![CDATA[<pre><code>[NSCursor hide];
[NSCursor unhide];
[NSCursor setHiddenUntilMouseMoves:YES];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Afficher la date</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a134</link>
                       <description>NSString *formattedDate = [[NSDate date] descriptionWithCalendarFormat:@"%Y-%m-%d %H:%M:%S"];


2006-11-15 00:26:11
</description>
                       <content:encoded><![CDATA[<pre><code>NSString *formattedDate = [[NSDate date] descriptionWithCalendarFormat:@"%Y-%m-%d %H:%M:%S"];
</code></pre>

<p>2006-11-15 00:26:11</p>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Afficher une fenêtre modale en tant que sheet</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a60</link>
                       <description>- (IBAction)openPrefsSheet:(id)sender {
         [NSApp beginSheet:prefsWindow 
            modalForWindow:mainWindow 
             modalDelegate:nil
            didEndSelector:nil
               contextInfo:nil];

    [NSApp runModalForWindow:prefsWindow];
    [NSApp endSheet:prefsWindow];
    [prefsWindow orderOut:self];
}

- (IBAction)closePrefsSheet:(id)sender {
    [NSApp stopModal];
}

</description>
                       <content:encoded><![CDATA[<pre><code>- (IBAction)openPrefsSheet:(id)sender {
         [NSApp beginSheet:prefsWindow 
            modalForWindow:mainWindow 
             modalDelegate:nil
            didEndSelector:nil
               contextInfo:nil];

    [NSApp runModalForWindow:prefsWindow];
    [NSApp endSheet:prefsWindow];
    [prefsWindow orderOut:self];
}

- (IBAction)closePrefsSheet:(id)sender {
    [NSApp stopModal];
}
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Archivage binaire d'un graphe d'objets</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a51</link>
                       <description>La classe à archiver doit implémenter le protocole NSCoding

@interface Cat : NSObject &lt; NSCoding &gt; {
    ...
}

@end


et ses méthodes :

@implementation Cat

- (void)encodeWithCoder:(NSCoder *)encoder {
    [encoder encodeObject:name forKey:@"Name"];
    [encoder encodeObject:dob forKey:@"BirthDate"];
}

- (id)initWithCoder:(NSCoder *)decoder {    
    // returned values are autoreleased
    [self setName: [decoder decodeObjectForKey:@"Name"]];
    [self setDob: [decoder decodeObjectForKey:@"BirthDate"]];

    return self;
}

@end


L'appellant peut alors archiver et désarchiver :

// archive
[NSKeyedArchiver archiveRootObject:cw toFile:@"/tmp/cArchive"];

// unarchive
Cat *cr = [NSKeyedUnarchiver unarchiveObjectWithFile:@"/tmp/cArchive"];

</description>
                       <content:encoded><![CDATA[<p>La classe à archiver doit implémenter le protocole <code>NSCoding</code></p>

<pre><code>@interface Cat : NSObject &lt; NSCoding &gt; {
    ...
}

@end
</code></pre>

<p>et ses méthodes :</p>

<pre><code>@implementation Cat

- (void)encodeWithCoder:(NSCoder *)encoder {
    [encoder encodeObject:name forKey:@"Name"];
    [encoder encodeObject:dob forKey:@"BirthDate"];
}

- (id)initWithCoder:(NSCoder *)decoder {    
    // returned values are autoreleased
    [self setName: [decoder decodeObjectForKey:@"Name"]];
    [self setDob: [decoder decodeObjectForKey:@"BirthDate"]];

    return self;
}

@end
</code></pre>

<p>L'appellant peut alors archiver et désarchiver :</p>

<pre><code>// archive
[NSKeyedArchiver archiveRootObject:cw toFile:@"/tmp/cArchive"];

// unarchive
Cat *cr = [NSKeyedUnarchiver unarchiveObjectWithFile:@"/tmp/cArchive"];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Cocoa regexp matching with NSPredicate</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a241</link>
                       <description>NSString *s = @"Hello World!";
NSString *re = @".*l{2}.*";
NSPredicate *p = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", re];

NSLog(@"Match: %d", [p evaluateWithObject:s]);

</description>
                       <content:encoded><![CDATA[<pre><code>NSString *s = @"Hello World!";
NSString *re = @".*l{2}.*";
NSPredicate *p = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", re];

NSLog(@"Match: %d", [p evaluateWithObject:s]);
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Convertir une NSDate en NSCalendarDate</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a220</link>
                       <description>NSDate *date = [NSDate date];
NSCalendarDate *calendarDate = [date dateWithCalendarFormat:nil timeZone:[NSTimeZone defaultTimeZone]];

</description>
                       <content:encoded><![CDATA[<pre><code>NSDate *date = [NSDate date];
NSCalendarDate *calendarDate = [date dateWithCalendarFormat:nil timeZone:[NSTimeZone defaultTimeZone]];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Créer et lever ses propres exceptions</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a50</link>
                       <description>Créer une classe MyException héritant de NSException, puis :

@try {
    NSException *e = [MyException exceptionWithName: @"MyError"
                                             reason: @"I threw this Exception"
                                           userInfo: nil];
    @throw e;
} @catch (MyException *e) {
    NSLog(@"Exception name   : %@", [e name]);
    NSLog(@"Exception reason : %@", [e reason]);
}


En Objective-C, la tradition est plutôt au valeurs de retour comme nil, NULL, NO ou aux codes d'erreur.
</description>
                       <content:encoded><![CDATA[<p>Créer une classe <code>MyException</code> héritant de <code>NSException</code>, puis :</p>

<pre><code>@try {
    NSException *e = [MyException exceptionWithName: @"MyError"
                                             reason: @"I threw this Exception"
                                           userInfo: nil];
    @throw e;
} @catch (MyException *e) {
    NSLog(@"Exception name   : %@", [e name]);
    NSLog(@"Exception reason : %@", [e reason]);
}
</code></pre>

<p>En Objective-C, la tradition est plutôt au valeurs de retour comme <code>nil</code>, <code>NULL</code>, <code>NO</code> ou aux codes d'erreur.</p>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Current Application Name</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a282</link>
                       <description>[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]

[[NSProcessInfo processInfo] processName]

</description>
                       <content:encoded><![CDATA[<pre><code>[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]

[[NSProcessInfo processInfo] processName]
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Default Images</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a280</link>
                       <description>NSImage *image = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kAlertNoteIcon)];

</description>
                       <content:encoded><![CDATA[<pre><code>NSImage *image = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kAlertNoteIcon)];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Display Image Loading</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a284</link>
                       <description>$ OBJC_PRINT_IMAGES=YES /Library/XcodeBuilds/Debug/HelloWorld 
objc[39331]: IMAGES: processing 28 newly-mapped images...

objc[39331]: IMAGES: loading image for /usr/lib/libobjc.A.dylib (supports GC)

objc[39331]: IMAGES: loading image for /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (supports GC)

objc[39331]: IMAGES: loading image for /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (supports GC)

objc[39331]: IMAGES: loading image for /Library/XcodeBuilds/Debug/HelloWorld

</description>
                       <content:encoded><![CDATA[<pre><code>$ OBJC_PRINT_IMAGES=YES /Library/XcodeBuilds/Debug/HelloWorld 
objc[39331]: IMAGES: processing 28 newly-mapped images...

objc[39331]: IMAGES: loading image for /usr/lib/libobjc.A.dylib (supports GC)

objc[39331]: IMAGES: loading image for /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (supports GC)

objc[39331]: IMAGES: loading image for /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (supports GC)

objc[39331]: IMAGES: loading image for /Library/XcodeBuilds/Debug/HelloWorld
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Ensure 64-Bit Readiness</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a281</link>
                       <description>/Developer/Extras/64BitConversion/ConvertCocoa64 MyClass.m

</description>
                       <content:encoded><![CDATA[<pre><code>/Developer/Extras/64BitConversion/ConvertCocoa64 MyClass.m
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Enumerate CoreData entities</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a245</link>
                       <description>for (NSEntityDescription *entity in [self managedObjectModel]) {
    NSLog(@"entity %@", entity.name);
}

</description>
                       <content:encoded><![CDATA[<pre><code>for (NSEntityDescription *entity in [self managedObjectModel]) {
    NSLog(@"entity %@", entity.name);
}
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Filtrer un tableau avec NSPredicate</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a133</link>
                       <description>Exemple : supprimer les lignes commençant par "--" :

-(NSString *)stringWithoutComments:(NSString *)string {
    NSArray *inputLines = [string componentsSeparatedByString:@"\n"];
    NSPredicate *commentsPredicate = [NSPredicate predicateWithFormat: @"SELF beginswith %@", @"--"];
    NSPredicate *notCommentsPredicate = [NSCompoundPredicate notPredicateWithSubpredicate:commentsPredicate];
    NSArray *filteredLines = [inputLines filteredArrayUsingPredicate:notCommentsPredicate];
    return [filteredLines componentsJoinedByString:@"\n"];
}

</description>
                       <content:encoded><![CDATA[<p>Exemple : supprimer les lignes commençant par "--" :</p>

<pre><code>-(NSString *)stringWithoutComments:(NSString *)string {
    NSArray *inputLines = [string componentsSeparatedByString:@"\n"];
    NSPredicate *commentsPredicate = [NSPredicate predicateWithFormat: @"SELF beginswith %@", @"--"];
    NSPredicate *notCommentsPredicate = [NSCompoundPredicate notPredicateWithSubpredicate:commentsPredicate];
    NSArray *filteredLines = [inputLines filteredArrayUsingPredicate:notCommentsPredicate];
    return [filteredLines componentsJoinedByString:@"\n"];
}
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Get Computer Network Image</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a279</link>
                       <description>[NSImage imageNamed:NSImageNameComputer]

</description>
                       <content:encoded><![CDATA[<pre><code>[NSImage imageNamed:NSImageNameComputer]
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Get th Desktop path</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a253</link>
                       <description>NSString *desktop = [NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES) objectAtIndex:0];

</description>
                       <content:encoded><![CDATA[<pre><code>NSString *desktop = [NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES) objectAtIndex:0];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Get the app version number</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a244</link>
                       <description>NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"];

</description>
                       <content:encoded><![CDATA[<pre><code>NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Info about the current process (os, environment, ...)</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a266</link>
                       <description>Lots of useful info, thanks to NSProcessInfo.

NSProcessInfo *pi = [NSProcessInfo processInfo];

NSLog(@"environment SHELL: %@", [[pi environment] objectForKey:@"SHELL"]);
NSLog(@"globallyUniqueString: %@", [pi globallyUniqueString]);
NSLog(@"hostName: %@", [pi hostName]);
NSLog(@"processIdentifier: %d", [pi processIdentifier]);
NSLog(@"processName: %@", [pi processName]);
[pi setProcessName:@"MyProcessNewName"];
NSLog(@"processName: %@", [pi processName]);
NSLog(@"operatingSystem: %d", [pi operatingSystem]);
NSLog(@"operatingSystemName: %@", [pi operatingSystemName]);
NSLog(@"operatingSystemVersionString: %@", [pi operatingSystemVersionString]);
NSLog(@"processorCount: %d", [pi processorCount]);
NSLog(@"activeProcessorCount: %d", [pi activeProcessorCount]);
NSLog(@"physicalMemory: %qu", [pi physicalMemory]);
NSLog(@"args: %@", [pi arguments]);


Output:

environment SHELL: /bin/bash
globallyUniqueString: F68E72F1-257C-4E93-B23D-BA3A0DD15603-47346-0001600092C640D8
hostName: nst.local
processIdentifier: 47346
processName: Untitled
processName: MyProcessNewName
operatingSystem: 5
operatingSystemName: NSMACHOperatingSystem
operatingSystemVersionString: Version 10.5.4 (Build 9E17)
processorCount: 2
activeProcessorCount: 2
physicalMemory: 2147483648
args: (
    "/Library/XCodeBuilds/Debug/Untitled"
)

</description>
                       <content:encoded><![CDATA[<p>Lots of useful info, thanks to <code>NSProcessInfo</code>.</p>

<pre><code>NSProcessInfo *pi = [NSProcessInfo processInfo];

NSLog(@"environment SHELL: %@", [[pi environment] objectForKey:@"SHELL"]);
NSLog(@"globallyUniqueString: %@", [pi globallyUniqueString]);
NSLog(@"hostName: %@", [pi hostName]);
NSLog(@"processIdentifier: %d", [pi processIdentifier]);
NSLog(@"processName: %@", [pi processName]);
[pi setProcessName:@"MyProcessNewName"];
NSLog(@"processName: %@", [pi processName]);
NSLog(@"operatingSystem: %d", [pi operatingSystem]);
NSLog(@"operatingSystemName: %@", [pi operatingSystemName]);
NSLog(@"operatingSystemVersionString: %@", [pi operatingSystemVersionString]);
NSLog(@"processorCount: %d", [pi processorCount]);
NSLog(@"activeProcessorCount: %d", [pi activeProcessorCount]);
NSLog(@"physicalMemory: %qu", [pi physicalMemory]);
NSLog(@"args: %@", [pi arguments]);
</code></pre>

<p>Output:</p>

<pre><code>environment SHELL: /bin/bash
globallyUniqueString: F68E72F1-257C-4E93-B23D-BA3A0DD15603-47346-0001600092C640D8
hostName: nst.local
processIdentifier: 47346
processName: Untitled
processName: MyProcessNewName
operatingSystem: 5
operatingSystemName: NSMACHOperatingSystem
operatingSystemVersionString: Version 10.5.4 (Build 9E17)
processorCount: 2
activeProcessorCount: 2
physicalMemory: 2147483648
args: (
    "/Library/XCodeBuilds/Debug/Untitled"
)
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Itérer sur un tableau</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a47</link>
                       <description>Pareil qu'en C.

int i;
int count;

count = [array count];

for (i = 0; i &lt; count; i++) {
    NSLog(@"%@", [array objectAtIndex:i]);
}


Avec un énumérateur.

NSEnumerator *enumerator;
enumerator = [array objectEnumerator];

NSObject *obj;

while (obj = [enumerator nextObject]) {
    NSLog(@"%@", obj);
}

</description>
                       <content:encoded><![CDATA[<p>Pareil qu'en C.</p>

<pre><code>int i;
int count;

count = [array count];

for (i = 0; i &lt; count; i++) {
    NSLog(@"%@", [array objectAtIndex:i]);
}
</code></pre>

<p>Avec un énumérateur.</p>

<pre><code>NSEnumerator *enumerator;
enumerator = [array objectEnumerator];

NSObject *obj;

while (obj = [enumerator nextObject]) {
    NSLog(@"%@", obj);
}
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Lancer une autre application</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a217</link>
                       <description>NSWorkspace *ws = [NSWorkspace sharedWorkspace];
BOOL appDidLaunch = [ws launchApplication:@"BluePhoneElite"];

</description>
                       <content:encoded><![CDATA[<pre><code>NSWorkspace *ws = [NSWorkspace sharedWorkspace];
BOOL appDidLaunch = [ws launchApplication:@"BluePhoneElite"];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Lire des données dans un fichier du bundle</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a55</link>
                       <description>Ici dans le cas d'un tableau.

NSBundle *bundle;
NSString *path;
NSArray *usefulData;

bundle = [NSBundle mainBundle];
path = [bundle pathForResource:@"userfulData"
                        ofType:@"plist"];
usefulData = [[NSArray alloc] initWithContentsOfFile:path];

</description>
                       <content:encoded><![CDATA[<p>Ici dans le cas d'un tableau.</p>

<pre><code>NSBundle *bundle;
NSString *path;
NSArray *usefulData;

bundle = [NSBundle mainBundle];
path = [bundle pathForResource:@"userfulData"
                        ofType:@"plist"];
usefulData = [[NSArray alloc] initWithContentsOfFile:path];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Mesurer le temps d'exécution d'un bout de code</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a82</link>
                       <description>NSDate *startDate = [NSDate date];
//...
NSLog(@"took %f seconds", [[NSDate date] timeIntervalSinceDate:startDate]);

</description>
                       <content:encoded><![CDATA[<pre><code>NSDate *startDate = [NSDate date];
//...
NSLog(@"took %f seconds", [[NSDate date] timeIntervalSinceDate:startDate]);
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Méthode pour créer un singleton</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a83</link>
                       <description>+ singleton {
    static Singleton *instance = nil;

    if (instance == nil) {
        instance = [[self alloc] init];
    }

    return instance;
}

</description>
                       <content:encoded><![CDATA[<pre><code>+ singleton {
    static Singleton *instance = nil;

    if (instance == nil) {
        instance = [[self alloc] init];
    }

    return instance;
}
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Minimal command-line example</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a231</link>
                       <description>#import &lt;Foundation/Foundation.h&gt;

/*
gcc -g -Wall -framework Foundation -o nslog nslog.m
*/

int main (void) {
&nbsp;&nbsp;&nbsp;&nbsp;NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
&nbsp;&nbsp;&nbsp;&nbsp;NSLog(@&quot;hello world&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;[pool release];
&nbsp;&nbsp;&nbsp;&nbsp;return (0);
}

</description>
                       <content:encoded><![CDATA[<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#683821;">#import &lt;Foundation/Foundation.h&gt;<br />
</span><br />
<span style="color:#236e25;">/*<br />
gcc -g -Wall -framework Foundation -o nslog nslog.m<br />
*/</span><br />
<br />
<span style="color:#881350;">int</span> <span style="color:#003369;">main </span>(<span style="color:#881350;">void</span>) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSAutoreleasePool</span> *pool = [[<span style="color:#400080;">NSAutoreleasePool</span> <span style="color:#ff0000;">alloc</span>] <span style="color:#6c0540;">init</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSLog</span>(<span style="color:#760f15;">@&quot;hello world&quot;</span>);<br />
&nbsp;&nbsp;&nbsp;&nbsp;[pool <span style="color:#ff0000;">release</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">return</span><span style="color:#003369;"> </span>(<span style="color:#0000ff;">0</span>);<br />
}<br />
</div>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Network hostname and addresses</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a246</link>
                       <description>NSArray *addresses = [[NSHost currentHost] addresses];
NSString *hostName = [[NSProcessInfo processInfo] hostName];

</description>
                       <content:encoded><![CDATA[<pre><code>NSArray *addresses = [[NSHost currentHost] addresses];
NSString *hostName = [[NSProcessInfo processInfo] hostName];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Number of dpi of an NSImageRep</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a265</link>
                       <description>float dpi = ([image pixelsWide] / [image size].width) * 72.0);

</description>
                       <content:encoded><![CDATA[<pre><code>float dpi = ([image pixelsWide] / [image size].width) * 72.0);
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Obtenir la liste des applications ouvertes</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a219</link>
                       <description>NSWorkspace * ws = [NSWorkspace sharedWorkspace];
NSArray *runningApps = [ws valueForKeyPath:@"launchedApplications.NSApplicationName"];

</description>
                       <content:encoded><![CDATA[<pre><code>NSWorkspace * ws = [NSWorkspace sharedWorkspace];
NSArray *runningApps = [ws valueForKeyPath:@"launchedApplications.NSApplicationName"];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Ouvrir une URL</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a62</link>
                       <description>[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:myURLString]];

</description>
                       <content:encoded><![CDATA[<pre><code>[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:myURLString]];
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Pretty debug logs</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a254</link>
                       <description>NSLog(@"%s:%d", __PRETTY_FUNCTION__, __LINE__);

+[AppDelegate initialize]:23


Thank you Stéphane.

NSLog(@"-[%@ %s]", isa, SELNAME(_cmd));

-[NSKVONotifying_AppDelegate awakeFromNib]

</description>
                       <content:encoded><![CDATA[<pre><code>NSLog(@"%s:%d", __PRETTY_FUNCTION__, __LINE__);

+[AppDelegate initialize]:23
</code></pre>

<p>Thank you Stéphane.</p>

<pre><code>NSLog(@"-[%@ %s]", isa, SELNAME(_cmd));

-[NSKVONotifying_AppDelegate awakeFromNib]
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Print the line number</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a238</link>
                       <description>NSLog(@"line %d", __LINE__);

</description>
                       <content:encoded><![CDATA[<pre><code>NSLog(@"line %d", __LINE__);
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Protocole NSTableDataSource</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a52</link>
                       <description>La source de données d'un NSTableView doit implémenter les méthodes suivantes :

Retourner le nombre de lignes :

- (int)numberOfRowsInTableView: (NSTableView *)aTableView


Retourner le contenu d'une cellule :

- (id)              tableView: (NSTableView *)aTableView
    objectValueForTableColumn: (NSTableColumn *)aTableColumn
                          row: (int)rowIndex


Modifier le contenu d'une cellule (optionnel)

- (void) tableView: (NSTableView *)aTableView
    setObjectValue: (id)anObject
    forTableColumn: (NSTableColumn *)aTableColumn
               row: (int)rowIndex

</description>
                       <content:encoded><![CDATA[<p>La source de données d'un <code>NSTableView</code> doit implémenter les méthodes suivantes :</p>

<p>Retourner le nombre de lignes :</p>

<pre><code>- (int)numberOfRowsInTableView: (NSTableView *)aTableView
</code></pre>

<p>Retourner le contenu d'une cellule :</p>

<pre><code>- (id)              tableView: (NSTableView *)aTableView
    objectValueForTableColumn: (NSTableColumn *)aTableColumn
                          row: (int)rowIndex
</code></pre>

<p>Modifier le contenu d'une cellule (optionnel)</p>

<pre><code>- (void) tableView: (NSTableView *)aTableView
    setObjectValue: (id)anObject
    forTableColumn: (NSTableColumn *)aTableColumn
               row: (int)rowIndex
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Quitter une autre application</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a216</link>
                       <description>NSDictionary *errors;
NSAppleScript *quitBPE;

quitBPE = [[NSAppleScript alloc] initWithSource:@"tell application \"BluePhoneElite\" to quit"];
[quitBPE executeAndReturnError:&amp;errors];
[quitBPE release];

if(errors != nil) {
    // manage error
}

</description>
                       <content:encoded><![CDATA[<pre><code>NSDictionary *errors;
NSAppleScript *quitBPE;

quitBPE = [[NSAppleScript alloc] initWithSource:@"tell application \"BluePhoneElite\" to quit"];
[quitBPE executeAndReturnError:&amp;errors];
[quitBPE release];

if(errors != nil) {
    // manage error
}
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Registering default NSUserDefaults</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a252</link>
                       <description>+ (void)initialize{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:@"NO", @"disableRulerAntiAliasing",
                                                                           @"YES", @"disableTracksAntiAliasing", nil];

    [defaults registerDefaults:appDefaults];
}

</description>
                       <content:encoded><![CDATA[<pre><code>+ (void)initialize{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:@"NO", @"disableRulerAntiAliasing",
                                                                           @"YES", @"disableTracksAntiAliasing", nil];

    [defaults registerDefaults:appDefaults];
}
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Runtime Version Check</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a234</link>
                       <description>if (floor(NSAppKitVersionNumber) &lt;= NSAppKitVersionNumber10_0) {
  /* On a 10.0.x or earlier system */
} else if (floor(NSAppKitVersionNumber) &lt;= NSAppKitVersionNumber10_1) {
  /* On a 10.1 - 10.1.x system */
} else if (floor(NSAppKitVersionNumber) &lt;= NSAppKitVersionNumber10_2) {
  /* On a 10.2 - 10.2.x system */
} else if (floor(NSAppKitVersionNumber) &lt;= NSAppKitVersionNumber10_3) {
  /* On a 10.3 - 10.3.x system */
} else if (floor(NSAppKitVersionNumber) &lt;= NSAppKitVersionNumber10_4) {
  /* On a 10.4 - 10.4.x system */
} else {
  /* Leopard or later system */
}


http://developer.apple.com/releasenotes/Cocoa/AppKit.html
</description>
                       <content:encoded><![CDATA[<pre><code>if (floor(NSAppKitVersionNumber) &lt;= NSAppKitVersionNumber10_0) {
  /* On a 10.0.x or earlier system */
} else if (floor(NSAppKitVersionNumber) &lt;= NSAppKitVersionNumber10_1) {
  /* On a 10.1 - 10.1.x system */
} else if (floor(NSAppKitVersionNumber) &lt;= NSAppKitVersionNumber10_2) {
  /* On a 10.2 - 10.2.x system */
} else if (floor(NSAppKitVersionNumber) &lt;= NSAppKitVersionNumber10_3) {
  /* On a 10.3 - 10.3.x system */
} else if (floor(NSAppKitVersionNumber) &lt;= NSAppKitVersionNumber10_4) {
  /* On a 10.4 - 10.4.x system */
} else {
  /* Leopard or later system */
}
</code></pre>

<p><a href="http://developer.apple.com/releasenotes/Cocoa/AppKit.html">http://developer.apple.com/releasenotes/Cocoa/AppKit.html</a></p>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Super Log</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a267</link>
                       <description>Logs filename, line number, function name and optional arguments.

#define superLog(format, ...) NSLog( @"File=%s Line=%d Function=%s " format, strrchr("/" __FILE__,'/')+1, __LINE__, __PRETTY_FUNCTION__, ## __VA_ARGS__ )


Example:

File=MyClass.m Line=16 Function=-[MyClass awakeFromNib]

</description>
                       <content:encoded><![CDATA[<p>Logs filename, line number, function name and optional arguments.</p>

<pre><code>#define superLog(format, ...) NSLog( @"File=%s Line=%d Function=%s " format, strrchr("/" __FILE__,'/')+1, __LINE__, __PRETTY_FUNCTION__, ## __VA_ARGS__ )
</code></pre>

<p>Example:</p>

<pre><code>File=MyClass.m Line=16 Function=-[MyClass awakeFromNib]
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Trace Objective-C Messages</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a283</link>
                       <description>$ NSObjCMessageLoggingEnabled=YES /Library/XcodeBuilds/Debug/HelloWorld 
2009-02-04 10:54:41.728 HelloWorld[39133:10b] Hello, World!
$ cat /tmp/msgSends-39133 
+ NSRecursiveLock NSObject initialize
+ NSRecursiveLock NSObject new
+ NSRecursiveLock NSObject alloc
...


Tracing can be activated selectively in code:

instrumentObjcMessageSends(YES);
// messages will be traced here
instrumentObjcMessageSends(NO);

</description>
                       <content:encoded><![CDATA[<pre><code>$ NSObjCMessageLoggingEnabled=YES /Library/XcodeBuilds/Debug/HelloWorld 
2009-02-04 10:54:41.728 HelloWorld[39133:10b] Hello, World!
$ cat /tmp/msgSends-39133 
+ NSRecursiveLock NSObject initialize
+ NSRecursiveLock NSObject new
+ NSRecursiveLock NSObject alloc
...
</code></pre>

<p>Tracing can be activated selectively in code:</p>

<pre><code>instrumentObjcMessageSends(YES);
// messages will be traced here
instrumentObjcMessageSends(NO);
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Traitement des exceptions</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a49</link>
                       <description>NSMutableArray *array = [NSMutableArray new];

@try {
    [array addObject:nil];
} @catch (NSException* e) {
    NSLog(@"%@", e);
} @finally {
    NSLog(@"over");
}

</description>
                       <content:encoded><![CDATA[<pre><code>NSMutableArray *array = [NSMutableArray new];

@try {
    [array addObject:nil];
} @catch (NSException* e) {
    NSLog(@"%@", e);
} @finally {
    NSLog(@"over");
}
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Utiliser des préférences</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a54</link>
                       <description>Comment utiliser le système de préférences, ici dans le cas d'un tableau.

NSUserDefaults *prefs;
NSMutableArray *records;

// read prefs at opening
- (void)awakeFromNib {
    prefs = [[NSUserDefaults standardUserDefaults] retain];

    if([prefs objectForKey:@"Records"] != nil) {
        records = [[NSMutableArray alloc] initWithArray:[prefs arrayForKey:@"Records"]];
    } else {
        records = [[NSMutableArray alloc] init];
    }

}

// save prefs
- (void) saveData {
    [prefs setObject:records forKey:@"Records"];
}

// dealloc
- (void) dealloc {
    [self saveData]; // just to be sure

    [prefs synchronize];
    [prefs release];
    [records release];

    [super dealloc];
}


Ne pas oublier de définir le "bundle identifier name" dans targets / myapp / cmd-i / properties / identifier.
</description>
                       <content:encoded><![CDATA[<p>Comment utiliser le système de préférences, ici dans le cas d'un tableau.</p>

<pre><code>NSUserDefaults *prefs;
NSMutableArray *records;

// read prefs at opening
- (void)awakeFromNib {
    prefs = [[NSUserDefaults standardUserDefaults] retain];

    if([prefs objectForKey:@"Records"] != nil) {
        records = [[NSMutableArray alloc] initWithArray:[prefs arrayForKey:@"Records"]];
    } else {
        records = [[NSMutableArray alloc] init];
    }

}

// save prefs
- (void) saveData {
    [prefs setObject:records forKey:@"Records"];
}

// dealloc
- (void) dealloc {
    [self saveData]; // just to be sure

    [prefs synchronize];
    [prefs release];
    [records release];

    [super dealloc];
}
</code></pre>

<p>Ne pas oublier de définir le "bundle identifier name" dans <em>targets / myapp / cmd-i / properties / identifier</em>.</p>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Utiliser Python.h</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a135</link>
                       <description>Télécharger un projet XCode de démonstration : CocoaPython.zip.

#import 
#import 

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    /* initialization */
    
    Py_Initialize();
    
    PyObject *sysModule = PyImport_ImportModule("sys");
    PyObject *sysModuleDict = PyModule_GetDict(sysModule);
    PyObject *pathObject = PyDict_GetItemString(sysModuleDict, "path");
    PyObject_CallMethod(pathObject, "insert", "(is)", 0, "../../");
    
    Py_DECREF(sysModule); // borrowed reference
    
    /* import and instantiate Cat */
    
    // from Cat import *
    PyObject *CatModule = PyImport_ImportModule("Cat");
    
    // c = Cat()
    PyObject *Cat = PyDict_GetItemString(PyModule_GetDict(CatModule), "Cat");
    PyObject *cat = PyObject_CallObject(Cat, NULL);
    
    Py_DECREF(CatModule);
    Py_DECREF(Cat);
    
    /* use Cat instance methods */
    
    // c.scream()
    // c.set_name("charly")
    // c.print_family("jack", "cathy", 4)
    
    PyObject_CallMethod(cat,"scream",NULL);
    PyObject_CallMethod(cat,"set_name", "(s)", "charly");
    PyObject_CallMethod(cat,"print_family", "(ssi)", "jack", "cathy", 4);
    
    // c.is_asleep()
    PyObject *is_asleep = PyObject_CallMethod(cat,"is_asleep",NULL);
    BOOL isAsleep = (Py_True == is_asleep);
    Py_DECREF(is_asleep);
    NSLog(@"%d", isAsleep);
    
    // c.name()
    PyObject *name = PyObject_CallMethod(cat,"name",NULL);
    NSString *catName = [NSString stringWithCString: PyString_AsString(name)];
    Py_DECREF(name);
    NSLog(@"%@", catName);
    
    /* termination */
    
    Py_DECREF(cat);
    Py_Finalize();
    
    [pool release];
    return 0;
}

</description>
                       <content:encoded><![CDATA[<p>Télécharger un projet XCode de démonstration : <a href="http://quickies.seriot.ch/download/CocoaPython.zip">CocoaPython.zip</a>.</p>

<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#683821;">#import <Foundation/Foundation.h><br />
#import <Python/Python.h><br />
</span><br />
<span style="color:#881350;">int</span> <span style="color:#003369;">main </span>(<span style="color:#881350;">int</span> argc, <span style="color:#881350;">const</span> <span style="color:#881350;">char</span> * argv[]) {<br />
    <span style="color:#400080;">NSAutoreleasePool</span> * pool = [[<span style="color:#400080;">NSAutoreleasePool</span> <span style="color:#ff0000;">alloc</span>] <span style="color:#6c0540;">init</span>];<br />
    <br />
    <span style="color:#236e25;">/* initialization */</span><br />
    <br />
    <span style="color:#003369;">Py_Initialize</span>();<br />
    <br />
    PyObject *sysModule = <span style="color:#003369;">PyImport_ImportModule</span>(<span style="color:#760f15;">"sys"</span>);<br />
    PyObject *sysModuleDict = <span style="color:#003369;">PyModule_GetDict</span>(sysModule);<br />
    PyObject *pathObject = <span style="color:#003369;">PyDict_GetItemString</span>(sysModuleDict, <span style="color:#760f15;">"path"</span>);<br />
    <span style="color:#003369;">PyObject_CallMethod</span>(pathObject, <span style="color:#760f15;">"insert"</span>, <span style="color:#760f15;">"(is)"</span>, <span style="color:#0000ff;">0</span>, <span style="color:#760f15;">"../../"</span>);<br />
    <br />
    <span style="color:#003369;">Py_DECREF</span>(sysModule); <span style="color:#236e25;">// borrowed reference<br />
</span>    <br />
    <span style="color:#236e25;">/* import and instantiate Cat */</span><br />
    <br />
    <span style="color:#236e25;">// from Cat import *<br />
</span>    PyObject *CatModule = <span style="color:#003369;">PyImport_ImportModule</span>(<span style="color:#760f15;">"Cat"</span>);<br />
    <br />
    <span style="color:#236e25;">// c = Cat()<br />
</span>    PyObject *Cat = <span style="color:#003369;">PyDict_GetItemString</span>(<span style="color:#003369;">PyModule_GetDict</span>(CatModule), <span style="color:#760f15;">"Cat"</span>);<br />
    PyObject *cat = <span style="color:#003369;">PyObject_CallObject</span>(Cat, <span style="color:#881350;">NULL</span>);<br />
    <br />
    <span style="color:#003369;">Py_DECREF</span>(CatModule);<br />
    <span style="color:#003369;">Py_DECREF</span>(Cat);<br />
    <br />
    <span style="color:#236e25;">/* use Cat instance methods */</span><br />
    <br />
    <span style="color:#236e25;">// c.scream()<br />
</span>    <span style="color:#236e25;">// c.set_name("charly")<br />
</span>    <span style="color:#236e25;">// c.print_family("jack", "cathy", 4)<br />
</span>    <br />
    <span style="color:#003369;">PyObject_CallMethod</span>(cat,<span style="color:#760f15;">"scream"</span>,<span style="color:#881350;">NULL</span>);<br />
    <span style="color:#003369;">PyObject_CallMethod</span>(cat,<span style="color:#760f15;">"set_name"</span>, <span style="color:#760f15;">"(s)"</span>, <span style="color:#760f15;">"charly"</span>);<br />
    <span style="color:#003369;">PyObject_CallMethod</span>(cat,<span style="color:#760f15;">"print_family"</span>, <span style="color:#760f15;">"(ssi)"</span>, <span style="color:#760f15;">"jack"</span>, <span style="color:#760f15;">"cathy"</span>, <span style="color:#0000ff;">4</span>);<br />
    <br />
    <span style="color:#236e25;">// c.is_asleep()<br />
</span>    PyObject *is_asleep = <span style="color:#003369;">PyObject_CallMethod</span>(cat,<span style="color:#760f15;">"is_asleep"</span>,<span style="color:#881350;">NULL</span>);<br />
    <span style="color:#881350;">BOOL</span> isAsleep = (Py_True == is_asleep);<br />
    <span style="color:#003369;">Py_DECREF</span>(is_asleep);<br />
    <span style="color:#400080;">NSLog</span>(<span style="color:#760f15;">@"%d"</span>, isAsleep);<br />
    <br />
    <span style="color:#236e25;">// c.name()<br />
</span>    PyObject *name = <span style="color:#003369;">PyObject_CallMethod</span>(cat,<span style="color:#760f15;">"name"</span>,<span style="color:#881350;">NULL</span>);<br />
    <span style="color:#400080;">NSString</span> *catName = [<span style="color:#400080;">NSString</span> <span style="color:#6c0540;">stringWithCString:</span> <span style="color:#003369;">PyString_AsString</span>(name)];<br />
    <span style="color:#003369;">Py_DECREF</span>(name);<br />
    <span style="color:#400080;">NSLog</span>(<span style="color:#760f15;">@"%@"</span>, catName);<br />
    <br />
    <span style="color:#236e25;">/* termination */</span><br />
    <br />
    <span style="color:#003369;">Py_DECREF</span>(cat);<br />
    <span style="color:#003369;">Py_Finalize</span>();<br />
    <br />
    [pool <span style="color:#ff0000;">release</span>];<br />
    <span style="color:#881350;">return</span> <span style="color:#0000ff;">0</span>;<br />
}<br />
</div>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Utiliser une API non documentée</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a61</link>
                       <description>Utiliser une API non documentée


extraire l'API du framework binaire avec l'utilitaire class-dump, exemple :

class-dump
    /System/Library/Frameworks/InstantMessage.framework/Versions/A/InstantMessage
    &gt; ~/InstantMessage.h

ajouter le framework au projet
importer l'API

#import "InstantMessage.h"



Rien ne garanti que l'API fonctionne toujours dans les futures versions du système.
</description>
                       <content:encoded><![CDATA[<p>Utiliser une API non documentée</p>

<ol>
<li><p>extraire l'API du framework binaire avec l'utilitaire <a href="http://homepage.mac.com/nygard/Projects/">class-dump</a>, exemple :</p>

<pre><code>class-dump
    /System/Library/Frameworks/InstantMessage.framework/Versions/A/InstantMessage
    &gt; ~/InstantMessage.h
</code></pre></li>
<li><p>ajouter le framework au projet</p></li>
<li><p>importer l'API</p>

<pre><code>#import "InstantMessage.h"
</code></pre></li>
</ol>

<p>Rien ne garanti que l'API fonctionne toujours dans les futures versions du système.</p>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Where to put Spotlight cache files</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=12#a255</link>
                       <description>~/Library/Caches/Metadata/app.bundle.identifier

</description>
                       <content:encoded><![CDATA[<pre><code>~/Library/Caches/Metadata/app.bundle.identifier
</code></pre>
]]></content:encoded>
                       <category>Cocoa/Objective-C</category>
                       </item><item>
                       <title>Code barre</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=6#a18</link>
                       <description>

Avec la macro code128.

\input code128
\codetext{021\ seriot.ch} % avec texte
%\code{021\ seriot.ch} % sans texte

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/codes_barre/code_barre.png" alt="Code barre" title="Code barre" /></p>

<p>Avec la macro <a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/code128.html">code128</a>.</p>

<pre><code>\input code128
\codetext{021\ seriot.ch} % avec texte
%\code{021\ seriot.ch} % sans texte
</code></pre>
]]></content:encoded>
                       <category>Codes barre</category>
                       </item><item>
                       <title>Code barre EAN</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=6#a19</link>
                       <description>

Avec la macro ean.

\input ean13
\ISBN 2-88074-488-1  \EAN 9-782880-744885


...

\input ean8
\EAN 1234-5670

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/codes_barre/codes_barre_ean.png" alt="Code barre EAN" title="Code barre EAN" /></p>

<p>Avec la macro <a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/ean.html">ean</a>.</p>

<pre><code>\input ean13
\ISBN 2-88074-488-1  \EAN 9-782880-744885
</code></pre>

<p>...</p>

<pre><code>\input ean8
\EAN 1234-5670
</code></pre>
]]></content:encoded>
                       <category>Codes barre</category>
                       </item><item>
                       <title>Liens</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=6#a20</link>
                       <description>lamarchefamily.net Barcode Generator, pour Mac OS X
</description>
                       <content:encoded><![CDATA[<p><a href="http://www.lamarchefamily.net/nakedsoft/">lamarchefamily.net</a> Barcode Generator, pour Mac OS X</p>
]]></content:encoded>
                       <category>Codes barre</category>
                       </item><item>
                       <title>Obtenir les logs d'un user sur une période donnée</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=33#a115</link>
                       <description>$ cvs log -wnicolas -d"2006-04-01&lt;2006-05-01" -S

</description>
                       <content:encoded><![CDATA[<pre><code>$ cvs log -wnicolas -d"2006-04-01&lt;2006-05-01" -S
</code></pre>
]]></content:encoded>
                       <category>CVS</category>
                       </item><item>
                       <title>Supprimer récursivement les dossiers CVS</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=33#a184</link>
                       <description>$ find -d . -name 'CVS' -exec rm -rf '{}' \; -print

</description>
                       <content:encoded><![CDATA[<pre><code>$ find -d . -name 'CVS' -exec rm -rf '{}' \; -print
</code></pre>
]]></content:encoded>
                       <category>CVS</category>
                       </item><item>
                       <title>Réparer les autorisations</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=30#a106</link>
                       <description>$ sudo diskutil repairPermissions /
</description>
                       <content:encoded><![CDATA[<p><code>$ sudo diskutil repairPermissions /</code></p>
]]></content:encoded>
                       <category>diskutil</category>
                       </item><item>
                       <title>Debuging dans les templates</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=39#a149</link>
                       <description>Affiche le contexte courant et les modules importés.

&lt;pre&gt;{% debug %}&lt;/pre&gt;


Permet de savoir quelles variables afficher, par exemple :

&lt;pre&gt;errors
{{ form.error_dict|pprint }}&lt;/pre&gt;

&lt;pre&gt;data
{{ form.data|pprint }}&lt;/pre&gt;

</description>
                       <content:encoded><![CDATA[<p>Affiche le contexte courant et les modules importés.</p>

<pre><code>&lt;pre&gt;{% debug %}&lt;/pre&gt;
</code></pre>

<p>Permet de savoir quelles variables afficher, par exemple :</p>

<pre><code>&lt;pre&gt;errors
{{ form.error_dict|pprint }}&lt;/pre&gt;

&lt;pre&gt;data
{{ form.data|pprint }}&lt;/pre&gt;
</code></pre>
]]></content:encoded>
                       <category>Django</category>
                       </item><item>
                       <title>Édition inline dans une vue générique</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=39#a153</link>
                       <description>models.py

class Poll(models.Model):
    question = models.CharField(maxlength = 200)

class Choice(models.Model):
    poll = models.ForeignKey(Poll, edit_inline=models.STACKED, num_in_admin=3)
    choice = models.CharField(maxlength = 200, core = True)
    votes = models.IntegerField(core = True)


urls.py

urlpatterns = patterns('',
    [...]
    (r'^poll_update/(?P&lt;object_id&gt;d+)/$', 'django.views.generic.create_update.update_object', {'model': Poll})
)


templates/my_app/poll_form.html

{% extends "base.html" %}
{% block content %}

&lt;pre&gt;errors
{{ form.error_dict|pprint }}&lt;/pre&gt;
&lt;pre&gt;data
{{ form.data|pprint }}&lt;/pre&gt;

&lt;p&gt;Today's question is: &lt;em&gt;{{ object.question }}&lt;/em&gt;&lt;/p&gt;

&lt;form method="POST" action="./"&gt;

     &lt;label for="id_question"&gt;Question:&lt;/label&gt;{{ form.question }}

       {% for the_choice in form.choice %}
        {{ the_choice.id }}

        &lt;TABLE&gt;
        &lt;TH&gt;&lt;label for="id_choice.{{ forloop.counter0 }}.choice"&gt;Choice
        &lt;TD&gt;{{ the_choice.choice }}
        &lt;TH&gt;&lt;label for="id_votes.{{ forloop.counter0 }}.votes"&gt;Votes
        &lt;TD&gt;{{ the_choice.votes }}
        &lt;/TABLE&gt;
   {% endfor %}

    &lt;input type="submit" /&gt;
&lt;/form&gt;

{% endblock %}

</description>
                       <content:encoded><![CDATA[<p>models.py</p>

<pre><code>class Poll(models.Model):
    question = models.CharField(maxlength = 200)

class Choice(models.Model):
    poll = models.ForeignKey(Poll, edit_inline=models.STACKED, num_in_admin=3)
    choice = models.CharField(maxlength = 200, core = True)
    votes = models.IntegerField(core = True)
</code></pre>

<p>urls.py</p>

<pre><code>urlpatterns = patterns('',
    [...]
    (r'^poll_update/(?P&lt;object_id&gt;d+)/$', 'django.views.generic.create_update.update_object', {'model': Poll})
)
</code></pre>

<p>templates/my_app/poll_form.html</p>

<pre><code>{% extends "base.html" %}
{% block content %}

&lt;pre&gt;errors
{{ form.error_dict|pprint }}&lt;/pre&gt;
&lt;pre&gt;data
{{ form.data|pprint }}&lt;/pre&gt;

&lt;p&gt;Today's question is: &lt;em&gt;{{ object.question }}&lt;/em&gt;&lt;/p&gt;

&lt;form method="POST" action="./"&gt;

     &lt;label for="id_question"&gt;Question:&lt;/label&gt;{{ form.question }}

       {% for the_choice in form.choice %}
        {{ the_choice.id }}

        &lt;TABLE&gt;
        &lt;TH&gt;&lt;label for="id_choice.{{ forloop.counter0 }}.choice"&gt;Choice
        &lt;TD&gt;{{ the_choice.choice }}
        &lt;TH&gt;&lt;label for="id_votes.{{ forloop.counter0 }}.votes"&gt;Votes
        &lt;TD&gt;{{ the_choice.votes }}
        &lt;/TABLE&gt;
   {% endfor %}

    &lt;input type="submit" /&gt;
&lt;/form&gt;

{% endblock %}
</code></pre>
]]></content:encoded>
                       <category>Django</category>
                       </item><item>
                       <title>Envoyer des emails</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=39#a188</link>
                       <description>views.py

from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'from@domain.ch',
    ['to@domain.ch'], fail_silently=False)


settings.py

EMAIL_HOST = 'domain.ch'
EMAIL_PORT = '25'
EMAIL_HOST_USER = 'username'
EMAIL_HOST_PASSWORD = 'xxxxxxxx'

</description>
                       <content:encoded><![CDATA[<p>views.py</p>

<pre><code>from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'from@domain.ch',
    ['to@domain.ch'], fail_silently=False)
</code></pre>

<p>settings.py</p>

<pre><code>EMAIL_HOST = 'domain.ch'
EMAIL_PORT = '25'
EMAIL_HOST_USER = 'username'
EMAIL_HOST_PASSWORD = 'xxxxxxxx'
</code></pre>
]]></content:encoded>
                       <category>Django</category>
                       </item><item>
                       <title>Force translation into a given language</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=39#a288</link>
                       <description>translate_into_german = gettext.translation('django', 'locale', ['de_DE'], fallback=True).ugettext
print translate_into_german("Code postal")

</description>
                       <content:encoded><![CDATA[<pre><code>translate_into_german = gettext.translation('django', 'locale', ['de_DE'], fallback=True).ugettext
print translate_into_german("Code postal")
</code></pre>
]]></content:encoded>
                       <category>Django</category>
                       </item><item>
                       <title>Générer et compiler les fichiers de langue</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=39#a129</link>
                       <description>$ make-messages.py -a
$ compile-messages.py

</description>
                       <content:encoded><![CDATA[<pre><code>$ make-messages.py -a
$ compile-messages.py
</code></pre>
]]></content:encoded>
                       <category>Django</category>
                       </item><item>
                       <title>Générer un fichier RSS</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=39#a189</link>
                       <description>En générant un fichier RSS à intervalle régulier, on n'effectue la requête qu'une seule fois et on évite de charger la bases de donnée à chaque consultation.

from django.conf import settings
from django.utils import feedgenerator
from nm.models import Newsitem
import os

def generate_rss(self):

    file_name = "latest_news.rss"
    file_path = os.sep.join([settings.MEDIA_ROOT, file_name])
    file_url = os.sep.join([settings.MEDIA_URL, "site_media", file_name])

    feed = feedgenerator.Rss201rev2Feed(
        title=u"Newsmemory",
        link=file_url,
        description=u"Dernières nouvelles",
        language=u"fr",
    )

    qs = Newsitem.objects.select_related().filter(...)[:50]

    for r in qs:
        text = "&lt;br /&gt;".join([r.source.name, "%s" % r.time, r.text]) 
        feed.add_item(title=r.title, link=r.get_absolute_url(), description="")

    fp = open(file_path, 'w')
    feed.write(fp, 'utf-8')
    fp.close()

</description>
                       <content:encoded><![CDATA[<p>En générant un fichier RSS à intervalle régulier, on n'effectue la requête qu'une seule fois et on évite de charger la bases de donnée à chaque consultation.</p>

<pre><code>from django.conf import settings
from django.utils import feedgenerator
from nm.models import Newsitem
import os

def generate_rss(self):

    file_name = "latest_news.rss"
    file_path = os.sep.join([settings.MEDIA_ROOT, file_name])
    file_url = os.sep.join([settings.MEDIA_URL, "site_media", file_name])

    feed = feedgenerator.Rss201rev2Feed(
        title=u"Newsmemory",
        link=file_url,
        description=u"Dernières nouvelles",
        language=u"fr",
    )

    qs = Newsitem.objects.select_related().filter(...)[:50]

    for r in qs:
        text = "&lt;br /&gt;".join([r.source.name, "%s" % r.time, r.text]) 
        feed.add_item(title=r.title, link=r.get_absolute_url(), description="")

    fp = open(file_path, 'w')
    feed.write(fp, 'utf-8')
    fp.close()
</code></pre>
]]></content:encoded>
                       <category>Django</category>
                       </item><item>
                       <title>Gérer les login et logout</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=39#a187</link>
                       <description>settings.py

INSTALLED_APPS = (
    'django.contrib.auth',
    [...]
)


urls.py

 (r'^accounts/login/$', 'django.contrib.auth.views.login'),
 (r'^accounts/logout/$', 'django.contrib.auth.views.logout'),


app_name/urls.py

(r'^accounts/profile/$',                              'sentools.invoice.views.index'), # default page after login


templates/app_name/registration/logged_out.html

templates/app_name/registration/loggin.html

{% block content %}

&lt;div id="box"&gt;&lt;h4&gt;Login&lt;/h4&gt;&lt;/div&gt;

{% if form.has_errors %}
&lt;div id="alert"&gt;
    &lt;p&gt;Your username and password didn't match. Please try again.&lt;/p&gt;
&lt;/div&gt;  
{% endif %}

{% if user.is_authenticated %}
&lt;div id="alert"&gt;
    &lt;p&gt;You are already logged in as "{{ user }}".&lt;/p&gt;
&lt;/div&gt;  
{% endif %}

&lt;form method="post" action="."&gt;
&lt;P&gt;
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;&lt;label for="id_username"&gt;Username:&lt;/label&gt;&lt;/td&gt;&lt;td&gt;{{ form.username }}&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;label for="id_password"&gt;Password:&lt;/label&gt;&lt;/td&gt;&lt;td&gt;{{ form.password }}&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/P&gt;
&lt;p&gt;
&lt;input type="submit" value="Login" /&gt;
&lt;input type="hidden" name="next" value="{{ next }}" /&gt;
&lt;/p&gt;
&lt;/form&gt;

{% endblock %}

</description>
                       <content:encoded><![CDATA[<p>settings.py</p>

<pre><code>INSTALLED_APPS = (
    'django.contrib.auth',
    [...]
)
</code></pre>

<p>urls.py</p>

<pre><code> (r'^accounts/login/$', 'django.contrib.auth.views.login'),
 (r'^accounts/logout/$', 'django.contrib.auth.views.logout'),
</code></pre>

<p>app_name/urls.py</p>

<pre><code>(r'^accounts/profile/$',                              'sentools.invoice.views.index'), # default page after login
</code></pre>

<p>templates/app_name/registration/logged_out.html</p>

<p>templates/app_name/registration/loggin.html</p>

<pre><code>{% block content %}

&lt;div id="box"&gt;&lt;h4&gt;Login&lt;/h4&gt;&lt;/div&gt;

{% if form.has_errors %}
&lt;div id="alert"&gt;
    &lt;p&gt;Your username and password didn't match. Please try again.&lt;/p&gt;
&lt;/div&gt;  
{% endif %}

{% if user.is_authenticated %}
&lt;div id="alert"&gt;
    &lt;p&gt;You are already logged in as "{{ user }}".&lt;/p&gt;
&lt;/div&gt;  
{% endif %}

&lt;form method="post" action="."&gt;
&lt;P&gt;
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;&lt;label for="id_username"&gt;Username:&lt;/label&gt;&lt;/td&gt;&lt;td&gt;{{ form.username }}&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;label for="id_password"&gt;Password:&lt;/label&gt;&lt;/td&gt;&lt;td&gt;{{ form.password }}&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/P&gt;
&lt;p&gt;
&lt;input type="submit" value="Login" /&gt;
&lt;input type="hidden" name="next" value="{{ next }}" /&gt;
&lt;/p&gt;
&lt;/form&gt;

{% endblock %}
</code></pre>
]]></content:encoded>
                       <category>Django</category>
                       </item><item>
                       <title>Utiliser des filtres personalisés dans les templates</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=39#a152</link>
                       <description>sentools/invoice/templatetags/

__init__.py
custom_filters.py


sentools/invoice/templatetags/custom_filters.py

from django import template
from django.conf import settings

def nop(value):
    return value[3:-4]

register = template.Library()
register.filter('nop', nop)


sentools/settings.py

INSTALLED_APPS = (
    'sentools.invoice'
)


sentools/templates/invoice/customer_detail.html

{% load custom_filters %}
{{ object.address|linebreaks|nop }}

</description>
                       <content:encoded><![CDATA[<p>sentools/invoice/templatetags/</p>

<pre><code>__init__.py
custom_filters.py
</code></pre>

<p>sentools/invoice/templatetags/custom_filters.py</p>

<pre><code>from django import template
from django.conf import settings

def nop(value):
    return value[3:-4]

register = template.Library()
register.filter('nop', nop)
</code></pre>

<p>sentools/settings.py</p>

<pre><code>INSTALLED_APPS = (
    'sentools.invoice'
)
</code></pre>

<p>sentools/templates/invoice/customer_detail.html</p>

<pre><code>{% load custom_filters %}
{{ object.address|linebreaks|nop }}
</code></pre>
]]></content:encoded>
                       <category>Django</category>
                       </item><item>
                       <title>Utiliser les fichiers graphiques et les widget de Django admin</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=39#a186</link>
                       <description>urls.py

urlpatterns = patterns('',
    [...]
     (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', {'packages': 'django.conf'}),
)


settings.py

ADMIN_MEDIA_PREFIX = '/media/'


template file

&lt;script type="text/javascript" src="/jsi18n/"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/media/js/core.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/media/js/admin/RelatedObjectLookups.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/media/js/calendar.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/media/js/admin/DateTimeShortcuts.js"&gt;&lt;/script&gt;

&lt;img src="/media/img/admin/icon_changelink.gif"&gt;

</description>
                       <content:encoded><![CDATA[<p>urls.py</p>

<pre><code>urlpatterns = patterns('',
    [...]
     (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', {'packages': 'django.conf'}),
)
</code></pre>

<p>settings.py</p>

<pre><code>ADMIN_MEDIA_PREFIX = '/media/'
</code></pre>

<p>template file</p>

<pre><code>&lt;script type="text/javascript" src="/jsi18n/"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/media/js/core.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/media/js/admin/RelatedObjectLookups.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/media/js/calendar.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/media/js/admin/DateTimeShortcuts.js"&gt;&lt;/script&gt;

&lt;img src="/media/img/admin/icon_changelink.gif"&gt;
</code></pre>
]]></content:encoded>
                       <category>Django</category>
                       </item><item>
                       <title>Équations alignées</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=7#a22</link>
                       <description>

\begin{eqnarray*}
\cos 2\theta &amp; = &amp; \cos^2 \theta - \sin^2 \theta \\
             &amp; = &amp; 2 \cos^2 \theta - 1
\end{eqnarray*}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/equations/equations_alignees.png" alt="Équations alignées" title="Équations alignées" /></p>

<pre><code>\begin{eqnarray*}
\cos 2\theta &amp; = &amp; \cos^2 \theta - \sin^2 \theta \\
             &amp; = &amp; 2 \cos^2 \theta - 1
\end{eqnarray*}
</code></pre>
]]></content:encoded>
                       <category>Équations</category>
                       </item><item>
                       <title>Système d'équations</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=7#a23</link>
                       <description>

En mode mathématique.

\left\{ \begin{array}{rrrrr}
   -9a &amp; -2b &amp; +6c &amp; = &amp; 11a \\
    6a &amp; -6b &amp; +7c &amp; = &amp; 11b \\
    2a &amp; +9b &amp; +6c &amp; = &amp; 11c
   \end{array}
\right.

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/equations/systeme_equations.png" alt="Système d'équations" title="Système d'équations" /></p>

<p>En mode mathématique.</p>

<pre><code>\left\{ \begin{array}{rrrrr}
   -9a &amp; -2b &amp; +6c &amp; = &amp; 11a \\
    6a &amp; -6b &amp; +7c &amp; = &amp; 11b \\
    2a &amp; +9b &amp; +6c &amp; = &amp; 11c
   \end{array}
\right.
</code></pre>
]]></content:encoded>
                       <category>Équations</category>
                       </item><item>
                       <title>Afficher les fichiers invsibles</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a158</link>
                       <description>$ defaults write com.apple.finder AppleShowAllFiles TRUE

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.finder AppleShowAllFiles TRUE
</code></pre>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Ajouter un menu Quitter au Finder</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a159</link>
                       <description>$ defaults write com.apple.finder QuitMenuItem -bool yes

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.finder QuitMenuItem -bool yes
</code></pre>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Ajuster la largeur des colonnes</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a161</link>
                       <description>En mode colonne, double-cliquer sur le ||.
</description>
                       <content:encoded><![CDATA[<p>En mode colonne, double-cliquer sur le ||.</p>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Change the Dock's look</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a232</link>
                       <description>$ defaults write com.apple.dock no-glass -boolean YES

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.dock no-glass -boolean YES
</code></pre>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Finder QuickLook plugin for .text clipping files</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a243</link>
                       <description>http://hetima.com/soft/clippingql-e.html
</description>
                       <content:encoded><![CDATA[<p><a href="http://hetima.com/soft/clippingql-e.html">http://hetima.com/soft/clippingql-e.html</a></p>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Imprimer le contenu d'un dossier</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a160</link>
                       <description>Glisser un dossier sur l'icône du Centre d'impression.
</description>
                       <content:encoded><![CDATA[<p>Glisser un dossier sur l'icône du Centre d'impression.</p>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Masquer le bureau en fond d'écran</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a104</link>
                       <description>$ defaults write com.apple.finder CreateDesktop -bool False

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.finder CreateDesktop -bool False
</code></pre>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Modifier le nom d'un fichier sélectionné</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a165</link>
                       <description>enter
</description>
                       <content:encoded><![CDATA[<p>enter</p>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Placer le point d'insertion dans le champ de recherche</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a164</link>
                       <description>Pomme-alt-F
</description>
                       <content:encoded><![CDATA[<p>Pomme-alt-F</p>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Rendre un fichier invisible</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a131</link>
                       <description>$ /Developer/Tools/SetFile -a V my_file.txt

</description>
                       <content:encoded><![CDATA[<pre><code>$ /Developer/Tools/SetFile -a V my_file.txt
</code></pre>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Supprimer les animations</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a162</link>
                       <description>$ defaults write com.apple.finder DisableAllAnimations -bool yes

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.finder DisableAllAnimations -bool yes
</code></pre>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Utiliser un économiseur d'écran en fond d'écran</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=28#a163</link>
                       <description>$ /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background

</description>
                       <content:encoded><![CDATA[<pre><code>$ /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background
</code></pre>
]]></content:encoded>
                       <category>Finder</category>
                       </item><item>
                       <title>Compiler un package en utilisant les binaires disponibles</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=46#a191</link>
                       <description>$ fink -b install wget-ssl

</description>
                       <content:encoded><![CDATA[<pre><code>$ fink -b install wget-ssl
</code></pre>
]]></content:encoded>
                       <category>fink</category>
                       </item><item>
                       <title>Graphe biparti</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=4#a3</link>
                       <description>

Avec les paquetages epic, eepic et eclbip.

\begin{bipartite}
   {1cm} % largeur étiquettes gauches
   {2cm} % largeur graphe
   {3cm} % largeur étiquettes droites
   {3mm} % hauteur max entre 2 noeuds
   {5mm} % larg. entre noeud et étiq.

\leftnode{a}
\leftnode{b}
\leftnode{c}
\rightnode[1]{chien}
\rightnode[2]{chat}
\rightnode[3]{lapin}
\rightnode[4]{renard}
\brush{\drawline}
\match{b}{2}
\match{b}{3}
\match{c}{4}
\match{a}{1}
\brush{\dottedline{3}}
\match{a}{2}
\end{bipartite}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/graphes/graphe_biparti.png" alt="Graphe biparti" title="Graphe biparti" /></p>

<p>Avec les paquetages epic, eepic et eclbip.</p>

<pre><code>\begin{bipartite}
   {1cm} % largeur étiquettes gauches
   {2cm} % largeur graphe
   {3cm} % largeur étiquettes droites
   {3mm} % hauteur max entre 2 noeuds
   {5mm} % larg. entre noeud et étiq.

\leftnode{a}
\leftnode{b}
\leftnode{c}
\rightnode[1]{chien}
\rightnode[2]{chat}
\rightnode[3]{lapin}
\rightnode[4]{renard}
\brush{\drawline}
\match{b}{2}
\match{b}{3}
\match{c}{4}
\match{a}{1}
\brush{\dottedline{3}}
\match{a}{2}
\end{bipartite}
</code></pre>
]]></content:encoded>
                       <category>Graphes</category>
                       </item><item>
                       <title>Graphe non pondéré orienté</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=4#a4</link>
                       <description>

Avec le paquetage pst-node.

\begin{psmatrix}[mnode=circle]
   &amp;   &amp; A         \\
 F &amp;   &amp; C &amp;   &amp; B \\
 D &amp;   &amp; E &amp;   &amp; G \\
   &amp; J &amp;   &amp; K
\end{psmatrix}

\psset{arrows=-&gt;}
\ncline{1,3}{2,1}
\ncline{1,3}{2,3}
\ncline{1,3}{2,5}
\ncline{2,5}{2,3}
\ncline{2,5}{3,5}
\ncline{2,3}{2,1}
\ncline{3,1}{2,3}
\ncline{3,3}{2,3}
\ncline{3,3}{3,1}
\ncline{3,3}{4,2}
\ncline{2,1}{3,1}
\ncline{3,5}{2,3}
\ncline{3,5}{3,3}
\ncline{4,2}{3,1}
\ncline{4,2}{4,4}
\ncline{4,4}{3,3}
\ncline{4,4}{3,5}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/graphes/graphe_non_pondere_oriente.png" alt="Graphe non pondéré orienté" title="Graphe non pondéré orienté" /></p>

<p>Avec le paquetage pst-node.</p>

<pre><code>\begin{psmatrix}[mnode=circle]
   &amp;   &amp; A         \\
 F &amp;   &amp; C &amp;   &amp; B \\
 D &amp;   &amp; E &amp;   &amp; G \\
   &amp; J &amp;   &amp; K
\end{psmatrix}

\psset{arrows=-&gt;}
\ncline{1,3}{2,1}
\ncline{1,3}{2,3}
\ncline{1,3}{2,5}
\ncline{2,5}{2,3}
\ncline{2,5}{3,5}
\ncline{2,3}{2,1}
\ncline{3,1}{2,3}
\ncline{3,3}{2,3}
\ncline{3,3}{3,1}
\ncline{3,3}{4,2}
\ncline{2,1}{3,1}
\ncline{3,5}{2,3}
\ncline{3,5}{3,3}
\ncline{4,2}{3,1}
\ncline{4,2}{4,4}
\ncline{4,4}{3,3}
\ncline{4,4}{3,5}
</code></pre>
]]></content:encoded>
                       <category>Graphes</category>
                       </item><item>
                       <title>Graphe pondéré non orienté</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=4#a5</link>
                       <description>

Avec le paquetage pst-node.

\begin{psmatrix}[mnode=circle] % pour réduire :
 A &amp;   &amp; B \\                  % [mnode=circle,colsep=1,rowsep=1]
   &amp; E     \\                  % défaut : rowsep et colsep = 1.5
 C &amp;   &amp; D
\end{psmatrix}

\psset{arrows=-,
       shortput=nab} % pondéré

\ncline{1,1}{1,3}^{1}
\ncline{1,1}{2,2}^{1}
\ncline{1,1}{3,1}^{4}
\ncline{1,3}{3,3}^{2}
\ncline{2,2}{1,3}^{1}
\ncline{2,2}{3,3}^{1}
\ncline{3,1}{2,2}^{2}
\ncline{3,1}{3,3}^{1}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/graphes/graphe_pondere_non_oriente.png" alt="Graphe pondéré non orienté" title="Graphe pondéré non orienté" /></p>

<p>Avec le paquetage pst-node.</p>

<pre><code>\begin{psmatrix}[mnode=circle] % pour réduire :
 A &amp;   &amp; B \\                  % [mnode=circle,colsep=1,rowsep=1]
   &amp; E     \\                  % défaut : rowsep et colsep = 1.5
 C &amp;   &amp; D
\end{psmatrix}

\psset{arrows=-,
       shortput=nab} % pondéré

\ncline{1,1}{1,3}^{1}
\ncline{1,1}{2,2}^{1}
\ncline{1,1}{3,1}^{4}
\ncline{1,3}{3,3}^{2}
\ncline{2,2}{1,3}^{1}
\ncline{2,2}{3,3}^{1}
\ncline{3,1}{2,2}^{2}
\ncline{3,1}{3,3}^{1}
</code></pre>
]]></content:encoded>
                       <category>Graphes</category>
                       </item><item>
                       <title>Graphe pondéré orienté</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=4#a6</link>
                       <description>

Avec le paquetage pst-node.

\begin{psmatrix}[mnode=circle]
     &amp; {v2}        \\
{v1} &amp;      &amp; {v4} \\
     &amp; {v3} &amp; 
\end{psmatrix}

\psset{arrows=-&gt;,
       shortput=nab}

\ncline{2,1}{1,2}^{3} 
\ncline{2,1}{3,2}^{1}
\ncline{1,2}{2,3}^{2}
\ncline{3,2}{2,3}^{3}

\ncarc[arcangle=10]{1,2}{3,2}^{1}
\ncarc[arcangle=10]{3,2}{1,2}^{1}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/graphes/graphe_pondere_oriente.png" alt="Graphe pondéré orienté" title="Graphe pondéré orienté" /></p>

<p>Avec le paquetage pst-node.</p>

<pre><code>\begin{psmatrix}[mnode=circle]
     &amp; {v2}        \\
{v1} &amp;      &amp; {v4} \\
     &amp; {v3} &amp; 
\end{psmatrix}

\psset{arrows=-&gt;,
       shortput=nab}

\ncline{2,1}{1,2}^{3} 
\ncline{2,1}{3,2}^{1}
\ncline{1,2}{2,3}^{2}
\ncline{3,2}{2,3}^{3}

\ncarc[arcangle=10]{1,2}{3,2}^{1}
\ncarc[arcangle=10]{3,2}{1,2}^{1}
</code></pre>
]]></content:encoded>
                       <category>Graphes</category>
                       </item><item>
                       <title>Graphe pondéré orienté 2</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=4#a7</link>
                       <description>

Avec le paquetage pst-node.

\begin{psmatrix}[mnode=circle]
         &amp;   &amp;   &amp; C &amp; E            \\
$\alpha$ &amp; A &amp; B &amp; D &amp;   &amp; $\omega$ \\
         &amp;   &amp;   &amp; F
\end{psmatrix}

\psset{arrows=-&gt;,
       labelsep=1mm,
       shortput=nab}

\ncline[linewidth=2pt]{2,1}{2,2}^{0} 
\ncline[linewidth=2pt]{2,2}{2,3}^{2} 
\ncline[linewidth=2pt]{2,3}{1,4}^{4} 
\ncline{2,3}{2,4}^{4} 
\ncline{2,3}{3,4}^{4}
\ncline[linewidth=2pt]{1,4}{1,5}^{3}
\ncline{2,4}{1,5}^{2}
\ncline{3,4}{2,6}^{4}
\ncline[linewidth=2pt]{1,5}{2,6}^{10}   


Une autre manière de faire exactement la même chose :

\begin{pspicture}(0,0)(14,8)
\cnodeput(2,4){a}{$\alpha$}
\cnodeput(4,4){A}{A}
\cnodeput(6,4){B}{B}
\cnodeput(8,6){C}{C}
\cnodeput(8,4){D}{D}
\cnodeput(8,2){F}{F}
\cnodeput(10,6){E}{E}
\cnodeput(12,4){o}{$\omega$}
%%%
\ncline[linewidth=2pt]{-&gt;}{a}{A} \Aput{0}
\ncline[linewidth=2pt]{-&gt;}{A}{B} \Aput{2}
\ncline[linewidth=2pt]{-&gt;}{B}{C} \Aput{4}
\ncline               {-&gt;}{B}{D} \Aput{4}
\ncline               {-&gt;}{B}{F} \Aput{4}
\ncline[linewidth=2pt]{-&gt;}{C}{E} \Aput{3}
\ncline               {-&gt;}{D}{E} \Aput{2}
\ncline[linewidth=2pt]{-&gt;}{E}{o} \Aput{10}
\ncline               {-&gt;}{F}{o} \Aput{4}
\end{pspicture}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/graphes/graphe_pondere_oriente_2.png" alt="Graphe pondéré orienté 2" title="Graphe pondéré orienté 2" /></p>

<p>Avec le paquetage pst-node.</p>

<pre><code>\begin{psmatrix}[mnode=circle]
         &amp;   &amp;   &amp; C &amp; E            \\
$\alpha$ &amp; A &amp; B &amp; D &amp;   &amp; $\omega$ \\
         &amp;   &amp;   &amp; F
\end{psmatrix}

\psset{arrows=-&gt;,
       labelsep=1mm,
       shortput=nab}

\ncline[linewidth=2pt]{2,1}{2,2}^{0} 
\ncline[linewidth=2pt]{2,2}{2,3}^{2} 
\ncline[linewidth=2pt]{2,3}{1,4}^{4} 
\ncline{2,3}{2,4}^{4} 
\ncline{2,3}{3,4}^{4}
\ncline[linewidth=2pt]{1,4}{1,5}^{3}
\ncline{2,4}{1,5}^{2}
\ncline{3,4}{2,6}^{4}
\ncline[linewidth=2pt]{1,5}{2,6}^{10}   
</code></pre>

<p>Une autre manière de faire exactement la même chose :</p>

<pre><code>\begin{pspicture}(0,0)(14,8)
\cnodeput(2,4){a}{$\alpha$}
\cnodeput(4,4){A}{A}
\cnodeput(6,4){B}{B}
\cnodeput(8,6){C}{C}
\cnodeput(8,4){D}{D}
\cnodeput(8,2){F}{F}
\cnodeput(10,6){E}{E}
\cnodeput(12,4){o}{$\omega$}
%%%
\ncline[linewidth=2pt]{-&gt;}{a}{A} \Aput{0}
\ncline[linewidth=2pt]{-&gt;}{A}{B} \Aput{2}
\ncline[linewidth=2pt]{-&gt;}{B}{C} \Aput{4}
\ncline               {-&gt;}{B}{D} \Aput{4}
\ncline               {-&gt;}{B}{F} \Aput{4}
\ncline[linewidth=2pt]{-&gt;}{C}{E} \Aput{3}
\ncline               {-&gt;}{D}{E} \Aput{2}
\ncline[linewidth=2pt]{-&gt;}{E}{o} \Aput{10}
\ncline               {-&gt;}{F}{o} \Aput{4}
\end{pspicture}
</code></pre>
]]></content:encoded>
                       <category>Graphes</category>
                       </item><item>
                       <title>Changer une adresse MAC</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=23#a71</link>
                       <description>$ sudo ifconfig en0 ether aa:bb:cc:dd:ee:ff

$ ifconfig en0
en0: flags=8863&lt;UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
        ether aa:bb:cc:dd:ee:ff 
        media: autoselect (none) status: inactive
        supported media: none autoselect 10baseT/UTP &lt;half-duplex&gt; ...

</description>
                       <content:encoded><![CDATA[<pre><code>$ sudo ifconfig en0 ether aa:bb:cc:dd:ee:ff

$ ifconfig en0
en0: flags=8863&lt;UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
        ether aa:bb:cc:dd:ee:ff 
        media: autoselect (none) status: inactive
        supported media: none autoselect 10baseT/UTP &lt;half-duplex&gt; ...
</code></pre>
]]></content:encoded>
                       <category>ifconfig</category>
                       </item><item>
                       <title>Ajouter une ombre floue sous une image</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=36#a120</link>
                       <description>$ convert picture.jpg \
    \( +clone -background black -shadow 70x4+5+5 \) +swap \
    -background none -flatten -trim +repage picture.png

</description>
                       <content:encoded><![CDATA[<pre><code>$ convert picture.jpg \
    \( +clone -background black -shadow 70x4+5+5 \) +swap \
    -background none -flatten -trim +repage picture.png
</code></pre>
]]></content:encoded>
                       <category>ImageMagick</category>
                       </item><item>
                       <title>Convertir un png en jpg en remplaçant la transparence par un fond blanc</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=36#a204</link>
                       <description>$ convert foo.png -resize 500x400 -background white -flatten foo.jpg


Source : http://www.imagemagick.org/
</description>
                       <content:encoded><![CDATA[<pre><code>$ convert foo.png -resize 500x400 -background white -flatten foo.jpg
</code></pre>

<p>Source : <a href="http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&amp;t=8359">http://www.imagemagick.org/</a></p>
]]></content:encoded>
                       <category>ImageMagick</category>
                       </item><item>
                       <title>Crop simulator screenshots to the screen</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=52#a263</link>
                       <description>- take a screenshot with cmd-alt-4-space
- open it in Acorn
- go to menu Image &gt; Crop
- from 47 151
- size 320 460

</description>
                       <content:encoded><![CDATA[<pre><code>- take a screenshot with cmd-alt-4-space
- open it in Acorn
- go to menu Image &gt; Crop
- from 47 151
- size 320 460
</code></pre>
]]></content:encoded>
                       <category>iPhone</category>
                       </item><item>
                       <title>Dump private headers</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=52#a274</link>
                       <description>sudo mkdir -p /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/System/Library/PrivateFrameworks/MusicLibrary.framework/Headers/

sudo class-dump-x -H /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/System/Library/PrivateFrameworks/MusicLibrary.framework/MusicLibrary -o /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/System/Library/PrivateFrameworks/MusicLibrary.framework/Headers/

</description>
                       <content:encoded><![CDATA[<pre><code>sudo mkdir -p /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/System/Library/PrivateFrameworks/MusicLibrary.framework/Headers/

sudo class-dump-x -H /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/System/Library/PrivateFrameworks/MusicLibrary.framework/MusicLibrary -o /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/System/Library/PrivateFrameworks/MusicLibrary.framework/Headers/
</code></pre>
]]></content:encoded>
                       <category>iPhone</category>
                       </item><item>
                       <title>Hide status bar</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=52#a260</link>
                       <description>- (void)applicationDidFinishLaunching:(UIApplication *)application {
    application.statusBarHidden = YES;
    // ...
}

</description>
                       <content:encoded><![CDATA[<pre><code>- (void)applicationDidFinishLaunching:(UIApplication *)application {
    application.statusBarHidden = YES;
    // ...
}
</code></pre>
]]></content:encoded>
                       <category>iPhone</category>
                       </item><item>
                       <title>Show error alert</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=52#a261</link>
                       <description>UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title"
                                                message:@"message"
                                               delegate:self
                                      cancelButtonTitle:@"OK"
                                      otherButtonTitles: nil];
[alert show];
[alert release];        

</description>
                       <content:encoded><![CDATA[<pre><code>UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title"
                                                message:@"message"
                                               delegate:self
                                      cancelButtonTitle:@"OK"
                                      otherButtonTitles: nil];
[alert show];
[alert release];        
</code></pre>
]]></content:encoded>
                       <category>iPhone</category>
                       </item><item>
                       <title>Obtenir le nom de l'utilisateur</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=37#a125</link>
                       <description>String username = System.getProperty("user.name");

</description>
                       <content:encoded><![CDATA[<pre><code>String username = System.getProperty("user.name");
</code></pre>
]]></content:encoded>
                       <category>Java</category>
                       </item><item>
                       <title>Read a file from inside a jar</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=37#a242</link>
                       <description>InputStream is = this.class.getResourceAsStream("file.txt");

</description>
                       <content:encoded><![CDATA[<pre><code>InputStream is = this.class.getResourceAsStream("file.txt");
</code></pre>
]]></content:encoded>
                       <category>Java</category>
                       </item><item>
                       <title>Unjar files</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=37#a235</link>
                       <description>$ jar xvf myjar.jar

</description>
                       <content:encoded><![CDATA[<pre><code>$ jar xvf myjar.jar
</code></pre>
]]></content:encoded>
                       <category>Java</category>
                       </item><item>
                       <title>Add an additional directory path for graphics for \includegraphics</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a264</link>
                       <description>\graphicspath{{./images/}}

</description>
                       <content:encoded><![CDATA[<pre><code>\graphicspath{{./images/}}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Algorithmes</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a8</link>
                       <description>

Avec les paquetages algorithmic et algorithm.

%%% francisation des algorithmes
\renewcommand{\algorithmicrequire} {\textbf{\textsc{Entrées:}}}
\renewcommand{\algorithmicensure}  {\textbf{\textsc{Sorties:}}}
\renewcommand{\algorithmicwhile}   {\textbf{tantque}}
\renewcommand{\algorithmicdo}      {\textbf{faire}}
\renewcommand{\algorithmicendwhile}{\textbf{fin tantque}}
\renewcommand{\algorithmicend}     {\textbf{fin}}
\renewcommand{\algorithmicif}      {\textbf{si}}
\renewcommand{\algorithmicendif}   {\textbf{finsi}}
\renewcommand{\algorithmicelse}    {\textbf{sinon}}
\renewcommand{\algorithmicthen}    {\textbf{alors}}
\renewcommand{\algorithmicfor}     {\textbf{pour}}
\renewcommand{\algorithmicforall}  {\textbf{pour tout}}
\renewcommand{\algorithmicdo}      {\textbf{faire}}
\renewcommand{\algorithmicendfor}  {\textbf{fin pour}}
\renewcommand{\algorithmicloop}    {\textbf{boucler}}
\renewcommand{\algorithmicendloop} {\textbf{fin boucle}}
\renewcommand{\algorithmicrepeat}  {\textbf{répéter}}
\renewcommand{\algorithmicuntil}   {\textbf{jusqu'à}}

\floatname{algorithm}{Algorithme}

\let\mylistof\listof
\renewcommand\listof[2]{\mylistof{algorithm}{Liste des algorithmes}}

% pour palier au problème de niveau des algos
\makeatletter
\providecommand*{\toclevel@algorithm}{0}
\makeatother

%\listofalgorithms % pour lister les algos (après la toc)


...

\begin{algorithm}
\caption{Algorithme d'Euclide}
\begin{algorithmic}
%%-----------------------------------------------
\REQUIRE $a, b \in {\mathbb N}$         % demande le paq. amssymb
\ENSURE le pgcd de $a$ et $b$

\STATE $x \leftarrow \textrm{max}(a,b)$
\STATE $y \leftarrow \textrm{min}(a,b)$

\WHILE {$y \neq 0$}
   \STATE $x \leftarrow y$
   \STATE $y \leftarrow x \mod y$       % demande le paq. amsmath
\ENDWHILE

\STATE Retourner $x$.
%%-----------------------------------------------
\end{algorithmic}
\end{algorithm}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/algorithmes.png" alt="Algorithmes" title="Algorithmes" /></p>

<p>Avec les paquetages <a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/algorithms.html">algorithmic et algorithm</a>.</p>

<pre><code>%%% francisation des algorithmes
\renewcommand{\algorithmicrequire} {\textbf{\textsc{Entrées:}}}
\renewcommand{\algorithmicensure}  {\textbf{\textsc{Sorties:}}}
\renewcommand{\algorithmicwhile}   {\textbf{tantque}}
\renewcommand{\algorithmicdo}      {\textbf{faire}}
\renewcommand{\algorithmicendwhile}{\textbf{fin tantque}}
\renewcommand{\algorithmicend}     {\textbf{fin}}
\renewcommand{\algorithmicif}      {\textbf{si}}
\renewcommand{\algorithmicendif}   {\textbf{finsi}}
\renewcommand{\algorithmicelse}    {\textbf{sinon}}
\renewcommand{\algorithmicthen}    {\textbf{alors}}
\renewcommand{\algorithmicfor}     {\textbf{pour}}
\renewcommand{\algorithmicforall}  {\textbf{pour tout}}
\renewcommand{\algorithmicdo}      {\textbf{faire}}
\renewcommand{\algorithmicendfor}  {\textbf{fin pour}}
\renewcommand{\algorithmicloop}    {\textbf{boucler}}
\renewcommand{\algorithmicendloop} {\textbf{fin boucle}}
\renewcommand{\algorithmicrepeat}  {\textbf{répéter}}
\renewcommand{\algorithmicuntil}   {\textbf{jusqu'à}}

\floatname{algorithm}{Algorithme}

\let\mylistof\listof
\renewcommand\listof[2]{\mylistof{algorithm}{Liste des algorithmes}}

% pour palier au problème de niveau des algos
\makeatletter
\providecommand*{\toclevel@algorithm}{0}
\makeatother

%\listofalgorithms % pour lister les algos (après la toc)
</code></pre>

<p>...</p>

<pre><code>\begin{algorithm}
\caption{Algorithme d'Euclide}
\begin{algorithmic}
%%-----------------------------------------------
\REQUIRE $a, b \in {\mathbb N}$         % demande le paq. amssymb
\ENSURE le pgcd de $a$ et $b$

\STATE $x \leftarrow \textrm{max}(a,b)$
\STATE $y \leftarrow \textrm{min}(a,b)$

\WHILE {$y \neq 0$}
   \STATE $x \leftarrow y$
   \STATE $y \leftarrow x \mod y$       % demande le paq. amsmath
\ENDWHILE

\STATE Retourner $x$.
%%-----------------------------------------------
\end{algorithmic}
\end{algorithm}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Alignements</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a16</link>
                       <description>

\begin{flushleft}
Voie lactée ô soeur lumineuse \\
Des blancs ruisseaux de Chanaan
\end{flushleft}

\begin{flushright}
Et des corps blancs des amoureuses \\
Nageurs morts suivrons-nous d'ahan
\end{flushright}

\begin{center}
Ton cours vers d'autres nébuleuses
\end{center}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/alignements.png" alt="Alignements" title="Alignements" /></p>

<pre><code>\begin{flushleft}
Voie lactée ô soeur lumineuse \\
Des blancs ruisseaux de Chanaan
\end{flushleft}

\begin{flushright}
Et des corps blancs des amoureuses \\
Nageurs morts suivrons-nous d'ahan
\end{flushright}

\begin{center}
Ton cours vers d'autres nébuleuses
\end{center}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Automate</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a15</link>
                       <description>Automate fini déterministe.



Avec le paquetage vaucanson-g.

\MediumPicture\VCDraw{% 
\begin{VCPicture}{(0,-4)(4,4)}
% states
\State[1]{(0,0)}{1}
\State[2]{(8,0)}{2}
\FinalState[3]{(4,0)}{3}
\State[4]{(0,-4)}{4}
\FinalState[5]{(4,-4)}{5}
% initial--final
\Initial{1}
%\Final{10}
% transitions 
\EdgeL{1}{3}{a}
\EdgeL{1}{4}{b}
\EdgeL{1}{5}{c}
\ArcL{2}{3}{a}
\EdgeL{2}{5}{c}
\LoopN{3}{a}
\ArcL{3}{2}{b}
\ArcL{3}{5}{c}
\ArcL{4}{5}{c}
\ArcL{5}{3}{a}
\ArcL{5}{4}{b}
\LoopS{5}{c}
\end{VCPicture}
}

</description>
                       <content:encoded><![CDATA[<p>Automate fini déterministe.</p>

<p><img src="http://quickies.seriot.ch/images/latex/automate.png" alt="Automate" title="Automate" /></p>

<p>Avec le paquetage <a href="http://www.liafa.jussieu.fr/~lombardy/Vaucanson-G/">vaucanson-g</a>.</p>

<pre><code>\MediumPicture\VCDraw{% 
\begin{VCPicture}{(0,-4)(4,4)}
% states
\State[1]{(0,0)}{1}
\State[2]{(8,0)}{2}
\FinalState[3]{(4,0)}{3}
\State[4]{(0,-4)}{4}
\FinalState[5]{(4,-4)}{5}
% initial--final
\Initial{1}
%\Final{10}
% transitions 
\EdgeL{1}{3}{a}
\EdgeL{1}{4}{b}
\EdgeL{1}{5}{c}
\ArcL{2}{3}{a}
\EdgeL{2}{5}{c}
\LoopN{3}{a}
\ArcL{3}{2}{b}
\ArcL{3}{5}{c}
\ArcL{4}{5}{c}
\ArcL{5}{3}{a}
\ArcL{5}{4}{b}
\LoopS{5}{c}
\end{VCPicture}
}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Calligraphie</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a17</link>
                       <description>

Avec la police French Cursive, les paquetages color et frcursive.

Police créée par Emmanuel Beffara.

\renewcommand{\seyesDefault}{\color{blue}}


...

\begin{document}


...

\begin{cursive}
  Vive l'école maternelle !

  \textbf{Gras}
  \textit{Italique} 
  \textcal{Calligraphie} % \calserie Calligraphie
\end{cursive}

\begin{quote}
  \cursive
  \seyes{Lignes normales.}
\end{quote}

\begin{quote}
  \cursive\acadshape
  \seyes[\color{red}]{Lignes comme au tableau.}
\end{quote}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/french_cursive.png" alt="Calligraphie enfantine" title="Calligraphie enfantine" /></p>

<p>Avec la police <a href="http://ebeffara.free.fr/stuff/frcursive/">French Cursive</a>, les paquetages color et <a href="http://ebeffara.free.fr/stuff/frcursive/">frcursive</a>.</p>

<p>Police créée par <a href="http://www.pps.jussieu.fr/~beffara/">Emmanuel Beffara</a>.</p>

<pre><code>\renewcommand{\seyesDefault}{\color{blue}}
</code></pre>

<p>...</p>

<pre><code>\begin{document}
</code></pre>

<p>...</p>

<pre><code>\begin{cursive}
  Vive l'école maternelle !

  \textbf{Gras}
  \textit{Italique} 
  \textcal{Calligraphie} % \calserie Calligraphie
\end{cursive}

\begin{quote}
  \cursive
  \seyes{Lignes normales.}
\end{quote}

\begin{quote}
  \cursive\acadshape
  \seyes[\color{red}]{Lignes comme au tableau.}
\end{quote}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Date et heure</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a14</link>
                       <description>

Avec le paquetage scrtime.

Nous sommes le \today, il est \thistime.


Sans paquetage particulier.

% ----------------------------------------------------------------------
% TIME OF DAY - Nelson Beebe - http://www.math.utah.edu/~beebe/
\newcount\hh
\newcount\mm
\mm=\time
\hh=\time
\divide\hh by 60
\divide\mm by 60
\multiply\mm by 60
\mm=-\mm
\advance\mm by \time
\def\hhmm{\number\hh:\ifnum\mm&lt;10{}0\fi\number\mm}
% ----------------------------------------------------------------------


...

Nous sommes le \today, il est \hhmm.

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/date_et_heure.png" alt="Date et heure" title="Date et heure" /></p>

<p>Avec le paquetage scrtime.</p>

<pre><code>Nous sommes le \today, il est \thistime.
</code></pre>

<p>Sans paquetage particulier.</p>

<pre><code>% ----------------------------------------------------------------------
% TIME OF DAY - Nelson Beebe - http://www.math.utah.edu/~beebe/
\newcount\hh
\newcount\mm
\mm=\time
\hh=\time
\divide\hh by 60
\divide\mm by 60
\multiply\mm by 60
\mm=-\mm
\advance\mm by \time
\def\hhmm{\number\hh:\ifnum\mm&lt;10{}0\fi\number\mm}
% ----------------------------------------------------------------------
</code></pre>

<p>...</p>

<pre><code>Nous sommes le \today, il est \hhmm.
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Écrire les siècles</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a21</link>
                       <description>

Une manière simple et élégante d'écrire les siècles, proposée par A. Chambert-Loir sur fr.comp.text.tex :

Avec la macro code128.

\def\siecle#1{\textsc{\romannumeral #1}\textsuperscript{e}~siècle}


...

Depuis le \siecle{19}, tout va mal !

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/siecles.png" alt="Siècles" title="Siècles" /></p>

<p>Une manière simple et élégante d'écrire les siècles, proposée par <a href="http://groups.google.com/groups?hl=en&amp;lr=&amp;ie=UTF-8&amp;oe=UTF-8&amp;c2coff=1&amp;selm=9qtv99%24uk3%241%40polynews.polytechnique.fr">A. Chambert-Loir</a> sur fr.comp.text.tex :</p>

<p>Avec la macro <a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/code128.html">code128</a>.</p>

<pre><code>\def\siecle#1{\textsc{\romannumeral #1}\textsuperscript{e}~siècle}
</code></pre>

<p>...</p>

<pre><code>Depuis le \siecle{19}, tout va mal !
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Exemple</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a26</link>
                       <description>

Avec le paquetage example.

\begin{example}
$$
\sum_{n=1}^{10} \cdot
\int_a^b e^{x} ~ dx
$$
\end{example}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/exemple.png" alt="Exemple" title="Exemple" /></p>

<p>Avec le paquetage example.</p>

<pre><code>\begin{example}
$$
\sum_{n=1}^{10} \cdot
\int_a^b e^{x} ~ dx
$$
\end{example}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Figures côte-à-côte</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a25</link>
                       <description>

Avec le paquetage graphicx.

\begin{figure}
\begin{minipage}[t]{.4\linewidth}
    \begin{center}
       \includegraphics[scale=0.5]{images/nb_abo.ps}
       \caption{nombre d'abonnements au téléphone}
       \label{nbabo}
    \end{center}
\end{minipage}
\hfill
\begin{minipage}[t]{.4\linewidth}
    \begin{center}
       \includegraphics[scale=0.5]{images/croiss_nb_abo.ps}
       \caption{croissance du nombre d'abonnements au téléphone}
       \label{croissnbabo}
    \end{center}
\end{minipage}
\end{figure}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/figures_cote_a_cote.png" alt="Figures côte-à-côte" title="Figures côte-à-côte" /></p>

<p>Avec le paquetage graphicx.</p>

<pre><code>\begin{figure}
\begin{minipage}[t]{.4\linewidth}
    \begin{center}
       \includegraphics[scale=0.5]{images/nb_abo.ps}
       \caption{nombre d'abonnements au téléphone}
       \label{nbabo}
    \end{center}
\end{minipage}
\hfill
\begin{minipage}[t]{.4\linewidth}
    \begin{center}
       \includegraphics[scale=0.5]{images/croiss_nb_abo.ps}
       \caption{croissance du nombre d'abonnements au téléphone}
       \label{croissnbabo}
    \end{center}
\end{minipage}
\end{figure}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Fractions</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a24</link>
                       <description>

(en mode mathématique)

% http://www.ctan.org/tex-archive/macros/eplain/
\def\fract#1/#2{\leavevmode
   \kern.1em \raise .5ex \hbox{\the\scriptfont0 #1}%
   \kern-.1em $/$%
   \kern-.15em \lower .25ex \hbox{\the\scriptfont0 #2}%
}% 
...
9\frac{1}{2}
...
9\fract 1/2

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/fractions.png" alt="Fractions" title="Fractions" /></p>

<p>(en mode mathématique)</p>

<pre><code>% http://www.ctan.org/tex-archive/macros/eplain/
\def\fract#1/#2{\leavevmode
   \kern.1em \raise .5ex \hbox{\the\scriptfont0 #1}%
   \kern-.1em $/$%
   \kern-.15em \lower .25ex \hbox{\the\scriptfont0 #2}%
}% 
...
9\frac{1}{2}
...
9\fract 1/2
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Interlignes</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a155</link>
                       <description>Avec le paquetage setspace.

\singlespace
\onehalfspace
\doublespace

</description>
                       <content:encoded><![CDATA[<p>Avec le paquetage setspace.</p>

<pre><code>\singlespace
\onehalfspace
\doublespace
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Listings package language definition for Objective-C 2.0</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a270</link>
                       <description>

\usepackage{color}
\usepackage{listings}

\definecolor{pink}  {rgb}{0.67, 0.05, 0.57} % keywords
\definecolor{red}   {rgb}{0.87, 0.20, 0.00} % strings
\definecolor{green} {rgb}{0.00, 0.47, 0.00} % comments
\definecolor{violet}{rgb}{0.41, 0.12, 0.61} % classes
\definecolor{blue}  {rgb}{0.21, 0.00, 0.44} % functions
\definecolor{brown} {rgb}{0.39, 0.22, 0.13} % brown

\lstdefinelanguage{Objective-C 2.0}[Objective]{C} {
    morekeywords={id, Class, SEL, IMP, BOOL, nil, Nil, NO, YES,
                  oneway, in, out, inout, bycopy, byref,
                  self, super, _cmd,
                  @required, @optional,
                  @try, @throw, @catch, @finally,
                  @synchronized, @property, @snythesize, @dynamic},
    moredelim=[s][color{red}]{@"}{"},
    moredelim=[s][color{red}]{&lt;}{&gt;}
}

\lstdefinestyle{Xcode} {
    language        = Objective-C 2.0,
    basicstyle      = footnotesizettfamily,
    identifierstyle = color{black},
    commentstyle    = color{green},
    keywordstyle    = color{pink},
    stringstyle     = color{red},
    directivestyle  = color{brown},
    extendedchars   = true,
    tabsize         = 4,
    showspaces      = false,
    showstringspaces = false,
    breakautoindent = true,
    flexiblecolumns = true,
    keepspaces      = true,
    stepnumber      = 0,
    xleftmargin     = 0pt}

\lstset{
    style = Xcode,
    caption=lstname,
    breaklines=false,
    frame=single
}


Use it like this:

\begin{lstlisting}[name=Sample code, label=SampleCode]
NSLog(@"hello");
\end{lstlisting}


List the listings:

\lstlistoflistings

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/listings_objc_2.png" alt="Listings for Objective-C 2.0" /></p>

<pre><code>\usepackage{color}
\usepackage{listings}

\definecolor{pink}  {rgb}{0.67, 0.05, 0.57} % keywords
\definecolor{red}   {rgb}{0.87, 0.20, 0.00} % strings
\definecolor{green} {rgb}{0.00, 0.47, 0.00} % comments
\definecolor{violet}{rgb}{0.41, 0.12, 0.61} % classes
\definecolor{blue}  {rgb}{0.21, 0.00, 0.44} % functions
\definecolor{brown} {rgb}{0.39, 0.22, 0.13} % brown

\lstdefinelanguage{Objective-C 2.0}[Objective]{C} {
    morekeywords={id, Class, SEL, IMP, BOOL, nil, Nil, NO, YES,
                  oneway, in, out, inout, bycopy, byref,
                  self, super, _cmd,
                  @required, @optional,
                  @try, @throw, @catch, @finally,
                  @synchronized, @property, @snythesize, @dynamic},
    moredelim=[s][color{red}]{@"}{"},
    moredelim=[s][color{red}]{&lt;}{&gt;}
}

\lstdefinestyle{Xcode} {
    language        = Objective-C 2.0,
    basicstyle      = footnotesizettfamily,
    identifierstyle = color{black},
    commentstyle    = color{green},
    keywordstyle    = color{pink},
    stringstyle     = color{red},
    directivestyle  = color{brown},
    extendedchars   = true,
    tabsize         = 4,
    showspaces      = false,
    showstringspaces = false,
    breakautoindent = true,
    flexiblecolumns = true,
    keepspaces      = true,
    stepnumber      = 0,
    xleftmargin     = 0pt}

\lstset{
    style = Xcode,
    caption=lstname,
    breaklines=false,
    frame=single
}
</code></pre>

<p>Use it like this:</p>

<pre><code>\begin{lstlisting}[name=Sample code, label=SampleCode]
NSLog(@"hello");
\end{lstlisting}
</code></pre>

<p>List the listings:</p>

<pre><code>\lstlistoflistings
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Matrices</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a27</link>
                       <description>

Avec le paquetage amsmath, et en mode mathématique.

\begin{matrix} 
a &amp; b \\
c &amp; d 
\end{matrix}
\quad
\begin{pmatrix} 
a &amp; b \\
c &amp; d 
\end{pmatrix}
\quad
\begin{bmatrix} 
a &amp; b \\
c &amp; d 
\end{bmatrix}
\quad
\begin{vmatrix} 
a &amp; b \\
c &amp; d 
\end{vmatrix}
\quad
\begin{Vmatrix} 
a &amp; b \\
c &amp; d 
\end{Vmatrix}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/matrices.png" alt="Matrices" title="Matrices" /></p>

<p>Avec le paquetage amsmath, et en mode mathématique.</p>

<pre><code>\begin{matrix} 
a &amp; b \\
c &amp; d 
\end{matrix}
\quad
\begin{pmatrix} 
a &amp; b \\
c &amp; d 
\end{pmatrix}
\quad
\begin{bmatrix} 
a &amp; b \\
c &amp; d 
\end{bmatrix}
\quad
\begin{vmatrix} 
a &amp; b \\
c &amp; d 
\end{vmatrix}
\quad
\begin{Vmatrix} 
a &amp; b \\
c &amp; d 
\end{Vmatrix}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Notes dans la marge</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a28</link>
                       <description>

\marginpar{Ben tiens !}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/note_marge.png" alt="Notes dans la marge" title="Notes dans la marge" /></p>

<pre><code>\marginpar{Ben tiens !}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Opérateur modulo</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a29</link>
                       <description>

On écrit $a\equiv b\pmod{c}$, \\
mais aussi $a = b \bmod c$.

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/modulo.png" alt="Opérateur modulo" title="Opérateur modulo" /></p>

<pre><code>On écrit $a\equiv b\pmod{c}$, \\
mais aussi $a = b \bmod c$.
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>PSTricks</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a46</link>
                       <description>Le Indian TeX Users Group propose une excellente introduction à PSTricks sous la forme de magnifiques fichiers PDF plein l'exemples et d'explications très bien choisis.

Ça se télécharge sur Sarovar, le SourceForge du pays de Gandhi.
</description>
                       <content:encoded><![CDATA[<p>Le <a href="http://www.tug.org.in/">Indian TeX Users Group</a> propose une excellente introduction à PSTricks sous la forme de magnifiques fichiers PDF plein l'exemples et d'explications très bien choisis.</p>

<p>Ça se télécharge sur <a href="http://sarovar.org/project/showfiles.php?group_id=12">Sarovar</a>, le SourceForge du pays de Gandhi.</p>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Section non numérotée</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a30</link>
                       <description>

Pour qu'une section (ou une sous-section, etc.) ne soit pas numérotée, il faut le signaler par une étoile.

\section*{Introduction}


Pour qu'elle apparaisse quand-même dans la table des matières, on peut ajouter la ligne suivante :

\addcontentsline{toc}{section}{Introduction}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/section_sans_num.png" alt="Section non numérotée" title="Section non numérotée" /></p>

<p>Pour qu'une section (ou une sous-section, etc.) ne soit pas numérotée, il faut le signaler par une étoile.</p>

<pre><code>\section*{Introduction}
</code></pre>

<p>Pour qu'elle apparaisse quand-même dans la table des matières, on peut ajouter la ligne suivante :</p>

<pre><code>\addcontentsline{toc}{section}{Introduction}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Symbole Euro</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a207</link>
                       <description>\usepackage{eurosym}

\euro

</description>
                       <content:encoded><![CDATA[<pre><code>\usepackage{eurosym}

\euro
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Texte barré</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a32</link>
                       <description>

Avec le paquetage ulem.

\sout{texte barré}


Avec le paquetage soul.

\st{texte barré}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/texte_barre.png" alt="Texte barré" title="Texte barré" /></p>

<p>Avec le paquetage ulem.</p>

<pre><code>\sout{texte barré}
</code></pre>

<p>Avec le paquetage soul.</p>

<pre><code>\st{texte barré}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Texte en couleur</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a31</link>
                       <description>

Avec le paquetage color.

\definecolor{orange}{rgb}{1.0, 0.5, 0.0}
\definecolor{monbleu}{rgb}{0.25, 0.25, 0.75}


...

\paragraph{}Je peux écrire en {\color{red}rouge}, en {\color{green}vert} et en {\color{blue}bleu}. \\
Je peux aussi écrire en {\color{orange}orange} ou avec {\color{monbleu}mon bleu}. \\
Ce n'est pas toujours \colorbox{monbleu}{\color{orange}très beau}.

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/texte_en_couleur.png" alt="Texte en couleur" title="Texte en couleur" /></p>

<p>Avec le paquetage color.</p>

<pre><code>\definecolor{orange}{rgb}{1.0, 0.5, 0.0}
\definecolor{monbleu}{rgb}{0.25, 0.25, 0.75}
</code></pre>

<p>...</p>

<pre><code>\paragraph{}Je peux écrire en {\color{red}rouge}, en {\color{green}vert} et en {\color{blue}bleu}. \\
Je peux aussi écrire en {\color{orange}orange} ou avec {\color{monbleu}mon bleu}. \\
Ce n'est pas toujours \colorbox{monbleu}{\color{orange}très beau}.
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Texte sur plusieurs colonnes</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a34</link>
                       <description>

Avec le paquetage multicol.

\begin{multicols}{3}


...

\end{multicols}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/plusieurs_colonnes.png" alt="Texte sur plusieurs colonnes" title="Texte sur plusieurs colonnes" /></p>

<p>Avec le paquetage multicol.</p>

<pre><code>\begin{multicols}{3}
</code></pre>

<p>...</p>

<pre><code>\end{multicols}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Texte surligné</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a33</link>
                       <description>

Avec les paquetages soul et color.

\definecolor{bleuclair}{rgb}{0.7, 0.7, 1.0}
\definecolor{rosepale}{rgb}{1.0, 0.7, 1.0}

\newcommand{\hlrose}[1]{\sethlcolor{rosepale}\hl{#1}}

\begin{document}

On peut \hl{surligner un texte avec la couleur par défaut}.

On peut choisir \hlrose{une autre couleur}.

\sethlcolor{bleuclair}

On peut aussi \hl{changer} la \hl{couleur} par \hl{défaut}.

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/texte_surligne.png" alt="Texte surligné" title="Texte surligné" /></p>

<p>Avec les paquetages soul et color.</p>

<pre><code>\definecolor{bleuclair}{rgb}{0.7, 0.7, 1.0}
\definecolor{rosepale}{rgb}{1.0, 0.7, 1.0}

\newcommand{\hlrose}[1]{\sethlcolor{rosepale}\hl{#1}}

\begin{document}

On peut \hl{surligner un texte avec la couleur par défaut}.

On peut choisir \hlrose{une autre couleur}.

\sethlcolor{bleuclair}

On peut aussi \hl{changer} la \hl{couleur} par \hl{défaut}.
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Typographie française</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a35</link>
                       <description>

Avec les paquetage babel et l'option francais.

\begin{tabular}{llll}
M\up{me}, M\up{mes}    &amp; Jean-Michel     &amp; 1\ier\ 1\iere\ 1\ieres  &amp; \og guillemets \fg          \\
M\up{lle}, M\up{lles}  &amp; pp.~12--15      &amp; 2\ieme\ 2\iemes         &amp; \nombre{1234,56}            \\
M. \bsc{Dupont},       &amp; --- en fait --- &amp; \No 1, \no 2            &amp; {\OE}uf, {\oe}ufs, \AE, \ae \\
M\up{e}, M\up{gr}, MM. &amp; $-1$ degrés     &amp; 13\degres, 23~\degres C &amp; À l'État.
\end{tabular}


Liens

perso.wanadoo.fr résumé des règles typographiques de base (générales et scientifiques)
listetypo.free.fr Orthotypographie [pdf], ouvrage posthume et inachevé, sur la page de Jean-Pierre Lacroux.
</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/typographie_francaise.png" alt="Typographie française" title="Typographie française" /></p>

<p>Avec les paquetage babel et l'option francais.</p>

<pre><code>\begin{tabular}{llll}
M\up{me}, M\up{mes}    &amp; Jean-Michel     &amp; 1\ier\ 1\iere\ 1\ieres  &amp; \og guillemets \fg          \\
M\up{lle}, M\up{lles}  &amp; pp.~12--15      &amp; 2\ieme\ 2\iemes         &amp; \nombre{1234,56}            \\
M. \bsc{Dupont},       &amp; --- en fait --- &amp; \No 1, \no 2            &amp; {\OE}uf, {\oe}ufs, \AE, \ae \\
M\up{e}, M\up{gr}, MM. &amp; $-1$ degrés     &amp; 13\degres, 23~\degres C &amp; À l'État.
\end{tabular}
</code></pre>

<p><strong>Liens</strong></p>

<p><a href="http://perso.wanadoo.fr">perso.wanadoo.fr</a> résumé des règles typographiques de base (générales et scientifiques)<br />
<a href="http://listetypo.free.fr">listetypo.free.fr</a> <em>Orthotypographie</em> [pdf], ouvrage posthume et inachevé, sur la page de <a href="http://listetypo.free.fr/JPL/">Jean-Pierre Lacroux</a>.</p>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>URLs</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=1#a36</link>
                       <description>

Avec le paquetage url.

\newcommand\email{\begingroup \urlstyle{rm}\Url}
\newcommand\web{\begingroup \urlstyle{tt}\Url}


...

\email{nicolas@seriot.ch}


...

\web{http://seriot.ch}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/urls.png" alt="URLs" title="URLs" /></p>

<p>Avec le paquetage url.</p>

<pre><code>\newcommand\email{\begingroup \urlstyle{rm}\Url}
\newcommand\web{\begingroup \urlstyle{tt}\Url}
</code></pre>

<p>...</p>

<pre><code>\email{nicolas@seriot.ch}
</code></pre>

<p>...</p>

<pre><code>\web{http://seriot.ch}
</code></pre>
]]></content:encoded>
                       <category>LaTeX</category>
                       </item><item>
                       <title>Listes énumérées 1</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=11#a44</link>
                       <description>

Sans paquetage particulier.

\begin{itemize}
\item chien
\item chat
\item renard
\item canari
\item éléphant
\end{itemize}


...

\begin{enumerate}
\item chien
\item chat
\item renard
\item canari
\item éléphant
\end{enumerate}


...

\begin{description}
\item[chien] habite dans une niche et mange des os
\item[renard] habite dans la forêt et mange des poules
\item[canari] habite dans une cage et mange des graines
\end{description}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/listes_enumerees/listes_enumerees.png" alt="Listes énumérées 1" title="Listes énumérées 1" /></p>

<p>Sans paquetage particulier.</p>

<pre><code>\begin{itemize}
\item chien
\item chat
\item renard
\item canari
\item éléphant
\end{itemize}
</code></pre>

<p>...</p>

<pre><code>\begin{enumerate}
\item chien
\item chat
\item renard
\item canari
\item éléphant
\end{enumerate}
</code></pre>

<p>...</p>

<pre><code>\begin{description}
\item[chien] habite dans une niche et mange des os
\item[renard] habite dans la forêt et mange des poules
\item[canari] habite dans une cage et mange des graines
\end{description}
</code></pre>
]]></content:encoded>
                       <category>Listes énumérées</category>
                       </item><item>
                       <title>Listes énumérées 2</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=11#a45</link>
                       <description>

Avec le paquetage enumerate.

\begin{enumerate}[1 --]
\item chien
\item chat
\item renard
\item canari
\item éléphant
\end{enumerate}


...

\begin{enumerate}[a)]
\item chien
\item chat
\item renard
\item canari
\item éléphant
\end{enumerate}


...

\begin{enumerate}[{ani.} i :]
\item chien
\item chat
\item renard
\item canari
\item éléphant
\end{enumerate}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/listes_enumerees/listes_enumerees_2.png" alt="Listes énumérées 2" title="Listes énumérées 2" /></p>

<p>Avec le paquetage enumerate.</p>

<pre><code>\begin{enumerate}[1 --]
\item chien
\item chat
\item renard
\item canari
\item éléphant
\end{enumerate}
</code></pre>

<p>...</p>

<pre><code>\begin{enumerate}[a)]
\item chien
\item chat
\item renard
\item canari
\item éléphant
\end{enumerate}
</code></pre>

<p>...</p>

<pre><code>\begin{enumerate}[{ani.} i :]
\item chien
\item chat
\item renard
\item canari
\item éléphant
\end{enumerate}
</code></pre>
]]></content:encoded>
                       <category>Listes énumérées</category>
                       </item><item>
                       <title>Choisir la version de gcc</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a198</link>
                       <description>$ sudo gcc_select 3.3
$ sudo gcc_select 4.0

</description>
                       <content:encoded><![CDATA[<pre><code>$ sudo gcc_select 3.3
$ sudo gcc_select 4.0
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Désactiver Dashboard</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a193</link>
                       <description>$ defaults write com.apple.dashboard mcx-disabled -boolean YES
$ killall Dock     

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.dashboard mcx-disabled -boolean YES
$ killall Dock     
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Désactiver la création de fichiers .DSStore sur les volumes réseau</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a196</link>
                       <description>$ defaults write com.apple.desktopservices DSDontWriteNetworkStores true


Voir http://docs.info.apple.com/article.html?artnum=301711
</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.desktopservices DSDontWriteNetworkStores true
</code></pre>

<p>Voir <a href="http://docs.info.apple.com/article.html?artnum=301711">http://docs.info.apple.com/article.html?artnum=301711</a></p>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Désactiver la vérification de la somme de contrôle au montage d'une image disque</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a112</link>
                       <description>$ defaults write com.apple.frameworks.diskimages skip-verify true

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.frameworks.diskimages skip-verify true
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Désactiver Spotlight</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a122</link>
                       <description>$ sudo mdutil -i off /

</description>
                       <content:encoded><![CDATA[<pre><code>$ sudo mdutil -i off /
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Exécuter les scripts de maintenance</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a195</link>
                       <description>$ sudo periodic daily weekly monthly

</description>
                       <content:encoded><![CDATA[<pre><code>$ sudo periodic daily weekly monthly
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Explorer la base CoreData avec F-Script</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a214</link>
                       <description>&gt; NSApplication sharedApplication delegate managedObjectContext inspectWithSystem:sys


illustration
</description>
                       <content:encoded><![CDATA[<pre><code>&gt; NSApplication sharedApplication delegate managedObjectContext inspectWithSystem:sys
</code></pre>

<p><a href="http://quickies.seriot.ch/images/cocoa/coredata_explorer.png">illustration</a></p>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Gagner un accès total à un Mac en ayant un accès physique</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a114</link>
                       <description>La manière la plus simple :


démarrer avec pomme-s
monter les disques

# mount /
supprimer le fichier .AppleSetupDone

# rm /var/db/.AppleSetupDone
redémarrer

# reboot
créer un nouveau compte admin à travers l'assistant

</description>
                       <content:encoded><![CDATA[<p>La manière la plus simple :</p>

<ol>
<li>démarrer avec pomme-s</li>
<li><p>monter les disques</p>

<p><code># mount /</code></p></li>
<li><p>supprimer le fichier .AppleSetupDone</p>

<p><code># rm /var/db/.AppleSetupDone</code></p></li>
<li><p>redémarrer</p>

<p><code># reboot</code></p></li>
<li><p>créer un nouveau compte admin à travers l'assistant</p></li>
</ol>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Gradient behind stack icons</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a248</link>
                       <description>$ defaults write com.apple.dock mouse-over-hilte-stack -boolean YES

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.dock mouse-over-hilte-stack -boolean YES
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Installer un package depuis une image disque en ligne de commande</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a192</link>
                       <description>$ hdiutil attach disk_image.dmg
$ cd /Volumes/volume_name/
$ sudo installer -pkg package_name.pkg -target "/"
$ hditutil detach /Volumes/volume_name/

</description>
                       <content:encoded><![CDATA[<pre><code>$ hdiutil attach disk_image.dmg
$ cd /Volumes/volume_name/
$ sudo installer -pkg package_name.pkg -target "/"
$ hditutil detach /Volumes/volume_name/
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Make Dock hidden icons transparent</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a249</link>
                       <description>$ defaults write com.apple.Dock showhidden -bool YES

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.Dock showhidden -bool YES
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Mettre un widget Dashboard sur le bureau</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a154</link>
                       <description>$ defaults write com.apple.dashboard devmode YES
$ killall Dock


Puis presser F12, commencer à déplacer le widget, pendant ce temps appuyer de nouveau sur F12, et placer le widget sur le bureau.

Pomme-R recharge le widget.
</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.dashboard devmode YES
$ killall Dock
</code></pre>

<p>Puis presser F12, commencer à déplacer le widget, pendant ce temps appuyer de nouveau sur F12, et placer le widget sur le bureau.</p>

<p>Pomme-R recharge le widget.</p>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Modifier le format des captures d'écran</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a156</link>
                       <description>$ defaults write com.apple.screencapture type jpg
$ killall SystemUIServer

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.screencapture type jpg
$ killall SystemUIServer
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Modifier le format des copies d'écran</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a197</link>
                       <description>$ defaults write com.apple.screencapture type &lt;format&gt;
$ killall SystemUIServer


 peut être : jpg, pdf, tif ou png (par défaut)
</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.screencapture type &lt;format&gt;
$ killall SystemUIServer
</code></pre>

<p><format> peut être : jpg, pdf, tif ou png (par défaut)</p>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Modifier le format des fichiers plist</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a157</link>
                       <description>$ plutil -convert xml1 BorkWalk.plist 
$ plutil -convert binary1 BorkWalk.plist 

</description>
                       <content:encoded><![CDATA[<pre><code>$ plutil -convert xml1 BorkWalk.plist 
$ plutil -convert binary1 BorkWalk.plist 
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Ne pas sortir de veille à l'ouverture du couvercle du PowerBook</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a127</link>
                       <description># sudo pmset lidwake 0

</description>
                       <content:encoded><![CDATA[<pre><code># sudo pmset lidwake 0
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Optimiser le temps de lancement des applications</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a167</link>
                       <description>Vous pouvez reproduire à tout moment l'optimisation qui a habituellement lieu après l'installation d'une mise à jour de Mac OS X, avec la commande suivante :

$ sudo update_prebinding -root /


Cela a pour effet d'optimiser le temps de lancement des applications.

Liens :

Un article à ce sujet, par Fabien Conus : cuk.ch

Prebinding Your Application : connect.apple.com
</description>
                       <content:encoded><![CDATA[<p>Vous pouvez reproduire à tout moment l'optimisation qui a habituellement lieu après l'installation d'une mise à jour de Mac OS X, avec la commande suivante :</p>

<pre><code>$ sudo update_prebinding -root /
</code></pre>

<p>Cela a pour effet d'optimiser le temps de lancement des applications.</p>

<p>Liens :</p>

<p>Un article à ce sujet, par Fabien Conus : <a href="http://www.cuk.ch/articles.php?unique=357">cuk.ch</a></p>

<p>Prebinding Your Application : <a href="http://developer.apple.com/documentation/Performance/Conceptual/LaunchTime/Tasks/Prebinding.html#//apple_ref/doc/uid/20001858/CJBJFIDD">connect.apple.com</a></p>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Prevent Spotlight from indexing a folder</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a256</link>
                       <description>End the directory name with .noindex.
</description>
                       <content:encoded><![CDATA[<p>End the directory name with .noindex.</p>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Réinitialiser les LaunchServices</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a199</link>
                       <description>$ /System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

</description>
                       <content:encoded><![CDATA[<pre><code>$ /System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Renseigner la valeur __companyname__ dans les fichiers XCode</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a126</link>
                       <description>$ defaults write com.apple.xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME="Ma société SA";}'

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME="Ma société SA";}'
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Supprimer les fichiers .DSStore</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a194</link>
                       <description>Récursivement, depuis le répertoire courant.

À aliaser avec une commande rmDS par exemple.

$ find . -name .DS_Store -ls -exec rm {} \;

</description>
                       <content:encoded><![CDATA[<p>Récursivement, depuis le répertoire courant.</p>

<p>À aliaser avec une commande <code>rmDS</code> par exemple.</p>

<pre><code>$ find . -name .DS_Store -ls -exec rm {} \;
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>URL of a man page in Terminal.app</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=41#a268</link>
                       <description>x-man-page://ls

</description>
                       <content:encoded><![CDATA[<pre><code>x-man-page://ls
</code></pre>
]]></content:encoded>
                       <category>Mac OS X</category>
                       </item><item>
                       <title>Enregistrer une mage man dans un fichier pdf</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=20#a81</link>
                       <description>$ man -t ls | pstopdf -i -o ls.pdf

</description>
                       <content:encoded><![CDATA[<pre><code>$ man -t ls | pstopdf -i -o ls.pdf
</code></pre>
]]></content:encoded>
                       <category>man</category>
                       </item><item>
                       <title>Enregistrer une page man dans un fichier texte</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=20#a69</link>
                       <description>$ man ls | col -bx &gt; ls.txt

</description>
                       <content:encoded><![CDATA[<pre><code>$ man ls | col -bx &gt; ls.txt
</code></pre>
]]></content:encoded>
                       <category>man</category>
                       </item><item>
                       <title>Afficher l'état d'une variable</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=38#a128</link>
                       <description>raise `my_var`

</description>
                       <content:encoded><![CDATA[<pre><code>raise `my_var`
</code></pre>
]]></content:encoded>
                       <category>mod_python</category>
                       </item><item>
                       <title>Afficher la liste des tables</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a95</link>
                       <description>mysql&gt; SHOW TABLES;

</description>
                       <content:encoded><![CDATA[<pre><code>mysql&gt; SHOW TABLES;
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Ajouter un index</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a94</link>
                       <description>mysql&gt; ALTER TABLE my_table ADD INDEX(my_col);

</description>
                       <content:encoded><![CDATA[<pre><code>mysql&gt; ALTER TABLE my_table ADD INDEX(my_col);
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Ajouter un index FULLTEXT</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a100</link>
                       <description>mysql&gt; ALTER TABLE my_table ADD FULLTEXT(my_col);


Cela ne fonctionne pas sur les tables de type InnoDB, seulement sur les MyIsam.

Les requêtes se font alors de la manière suivante :

SELECT *
FROM my_table
WHERE MATCH (my_col)
AGAINST('my_text');

</description>
                       <content:encoded><![CDATA[<pre><code>mysql&gt; ALTER TABLE my_table ADD FULLTEXT(my_col);
</code></pre>

<p>Cela ne fonctionne pas sur les tables de type InnoDB, seulement sur les MyIsam.</p>

<p>Les requêtes se font alors de la manière suivante :</p>

<pre><code>SELECT *
FROM my_table
WHERE MATCH (my_col)
AGAINST('my_text');
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Ajouter une contrainte d'unicité sur une colonne</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a183</link>
                       <description>mysql&gt; ALTER TABLE nm_newsitem ADD CONSTRAINT unique_link UNIQUE (link(255));

</description>
                       <content:encoded><![CDATA[<pre><code>mysql&gt; ALTER TABLE nm_newsitem ADD CONSTRAINT unique_link UNIQUE (link(255));
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Analyser une table</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a92</link>
                       <description>mysql&gt; ANALYZE TABLE my_table;

</description>
                       <content:encoded><![CDATA[<pre><code>mysql&gt; ANALYZE TABLE my_table;
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Arrêter le serveur</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a85</link>
                       <description>$ mysqladmin -u root --password=xxxxxxxx shutdown

</description>
                       <content:encoded><![CDATA[<pre><code>$ mysqladmin -u root --password=xxxxxxxx shutdown
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Choisir la base de données</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a91</link>
                       <description>mysql&gt; USE my_db;

</description>
                       <content:encoded><![CDATA[<pre><code>mysql&gt; USE my_db;
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Décrire la structure d'une table</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a97</link>
                       <description>mysql&gt; DESCRIBE my_table;

</description>
                       <content:encoded><![CDATA[<pre><code>mysql&gt; DESCRIBE my_table;
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Démarrer le serveur</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a84</link>
                       <description>$ sudo mysqld_safe --user=root &amp;

</description>
                       <content:encoded><![CDATA[<pre><code>$ sudo mysqld_safe --user=root &amp;
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Exporter la structure d'une base</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a107</link>
                       <description>$ mysqldump --no-data --opt --user=root --password news_memory &gt; tables.sql

</description>
                       <content:encoded><![CDATA[<pre><code>$ mysqldump --no-data --opt --user=root --password news_memory &gt; tables.sql
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Exporter une base</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a87</link>
                       <description>$ mysqldump --opt --user=username --password database &gt; dumpfile.sql

$ mysqldump --user my_user --password=my_password database &gt; dumpfile.sql

</description>
                       <content:encoded><![CDATA[<pre><code>$ mysqldump --opt --user=username --password database &gt; dumpfile.sql

$ mysqldump --user my_user --password=my_password database &gt; dumpfile.sql
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Importer une base</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a88</link>
                       <description>$ mysql --user=username --password database &lt; dumpfile.sql

</description>
                       <content:encoded><![CDATA[<pre><code>$ mysql --user=username --password database &lt; dumpfile.sql
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Insérer des données</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a98</link>
                       <description>mysql&gt; INSERT INTO my_table VALUES ('','France','fr');

</description>
                       <content:encoded><![CDATA[<pre><code>mysql&gt; INSERT INTO my_table VALUES ('','France','fr');
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Modifier des données</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a99</link>
                       <description>mysql&gt; UPDATE my_table SET my_table.my_row_1 = 'Lausanne' WHERE my_table.my_row_2 = 2338;

</description>
                       <content:encoded><![CDATA[<pre><code>mysql&gt; UPDATE my_table SET my_table.my_row_1 = 'Lausanne' WHERE my_table.my_row_2 = 2338;
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Optimiser une table</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a93</link>
                       <description>mysql&gt; OPTIMIZE TABLE my_table;

</description>
                       <content:encoded><![CDATA[<pre><code>mysql&gt; OPTIMIZE TABLE my_table;
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Rechercher / remplacer dans un champ</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a48</link>
                       <description>update &lt;table&gt; set &lt;champ&gt; = replace(&lt;champ&gt;,'&lt;avant&gt;','&lt;apres&gt;');

</description>
                       <content:encoded><![CDATA[<pre><code>update &lt;table&gt; set &lt;champ&gt; = replace(&lt;champ&gt;,'&lt;avant&gt;','&lt;apres&gt;');
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Réinitialiser le compteur d'incrémentation</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a108</link>
                       <description>ALTER TABLE my_table AUTO_INCREMENT=1;


La valeur est celle du prochain id à utiliser.
</description>
                       <content:encoded><![CDATA[<pre><code>ALTER TABLE my_table AUTO_INCREMENT=1;
</code></pre>

<p>La valeur est celle du prochain id à utiliser.</p>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Se connecter au serveur</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a96</link>
                       <description>$ mysql -u user_name -p

</description>
                       <content:encoded><![CDATA[<pre><code>$ mysql -u user_name -p
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Sécuriser un minimum</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a86</link>
                       <description>Après l'installation :

$ /usr/local/mysql/bin/mysqladmin -u root password xxxxxxxx

</description>
                       <content:encoded><![CDATA[<p>Après l'installation :</p>

<pre><code>$ /usr/local/mysql/bin/mysqladmin -u root password xxxxxxxx
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Utiliser des champs UTF-8</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a121</link>
                       <description>À partir de MySQL 4.1 :

mysql&gt; ALTER TABLE ma_table MODIFY ma_colonne CHAR(150) CHARACTER SET utf8;

</description>
                       <content:encoded><![CDATA[<p>À partir de MySQL 4.1 :</p>

<pre><code>mysql&gt; ALTER TABLE ma_table MODIFY ma_colonne CHAR(150) CHARACTER SET utf8;
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Utiliser l'ancien système de mot de passe</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=14#a90</link>
                       <description>À partir de la version 4.1, MySQL stocke les mots de passe de manière différente. Les anciens clients ne peuvent plus s'authentifier. Pour contourner ce problème, on peut mettre à jour les mots de passe de chaque utilisateur qui se trouve dans la table mysql.user :

mysql&gt; UPDATE mysql.user SET password = OLD_PASSWORD('password') WHERE user = 'xxx' and host = 'xxx';
FLUSH PRIVILEGES;

</description>
                       <content:encoded><![CDATA[<p>À partir de la version 4.1, MySQL stocke les mots de passe de manière différente. Les anciens clients ne peuvent plus s'authentifier. Pour contourner ce problème, on peut mettre à jour les mots de passe de chaque utilisateur qui se trouve dans la table mysql.user :</p>

<pre><code>mysql&gt; UPDATE mysql.user SET password = OLD_PASSWORD('password') WHERE user = 'xxx' and host = 'xxx';
FLUSH PRIVILEGES;
</code></pre>
]]></content:encoded>
                       <category>MySQL</category>
                       </item><item>
                       <title>Se loguer sur un serveur</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=19#a68</link>
                       <description>$ ncftp
ncftp&gt; open -u catane colons.seriot.ch 
Password: 
ncftp / &gt; 

</description>
                       <content:encoded><![CDATA[<pre><code>$ ncftp
ncftp&gt; open -u catane colons.seriot.ch 
Password: 
ncftp / &gt; 
</code></pre>
]]></content:encoded>
                       <category>ncftp</category>
                       </item><item>
                       <title>Alerte modale</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=15#a57</link>
                       <description>if([alert runModal] == NSAlertFirstButtonReturn) {
    // OK clicked, delete the record
}

[alert release];

</description>
                       <content:encoded><![CDATA[<pre><code>if([alert runModal] == NSAlertFirstButtonReturn) {
    // OK clicked, delete the record
}

[alert release];
</code></pre>
]]></content:encoded>
                       <category>NSAlert</category>
                       </item><item>
                       <title>Alerte sous forme de sheet</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=15#a58</link>
                       <description>[alert beginSheetModalForWindow:mainWindow
                  modalDelegate:self
                 didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
                    contextInfo:nil];

[alert release];


Le délégué doit implémenter la méthode :

- (void)alertDidEnd:(NSAlert *)alert
         returnCode:(int)returnCode
        contextInfo:(void *)contextInfo {
    if(returnCode == NSAlertFirstButtonReturn) {
        // OK clicked, delete the record
    }
}

</description>
                       <content:encoded><![CDATA[<pre><code>[alert beginSheetModalForWindow:mainWindow
                  modalDelegate:self
                 didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
                    contextInfo:nil];

[alert release];
</code></pre>

<p>Le délégué doit implémenter la méthode :</p>

<pre><code>- (void)alertDidEnd:(NSAlert *)alert
         returnCode:(int)returnCode
        contextInfo:(void *)contextInfo {
    if(returnCode == NSAlertFirstButtonReturn) {
        // OK clicked, delete the record
    }
}
</code></pre>
]]></content:encoded>
                       <category>NSAlert</category>
                       </item><item>
                       <title>Constantes</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=15#a59</link>
                       <description>Le style de l'alerte peut être :


NSWarningAlertStyle
NSInformationalAlertStyle
NSCriticalAlertStyle


Le résultat peut être :


NSAlertFirstButtonReturn
NSAlertSecondButtonReturn
NSAlertThirdButtonReturn

</description>
                       <content:encoded><![CDATA[<p>Le style de l'alerte peut être :</p>

<ul>
<li><code>NSWarningAlertStyle</code></li>
<li><code>NSInformationalAlertStyle</code></li>
<li><code>NSCriticalAlertStyle</code></li>
</ul>

<p>Le résultat peut être :</p>

<ul>
<li><code>NSAlertFirstButtonReturn</code></li>
<li><code>NSAlertSecondButtonReturn</code></li>
<li><code>NSAlertThirdButtonReturn</code></li>
</ul>
]]></content:encoded>
                       <category>NSAlert</category>
                       </item><item>
                       <title>Crééer une alerte</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=15#a56</link>
                       <description>NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:@"Delete the record?"];
[alert setInformativeText:@"Deleted records cannot be restored."];
[alert setAlertStyle:NSWarningAlertStyle];

</description>
                       <content:encoded><![CDATA[<pre><code>NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:@"Delete the record?"];
[alert setInformativeText:@"Deleted records cannot be restored."];
[alert setAlertStyle:NSWarningAlertStyle];
</code></pre>
]]></content:encoded>
                       <category>NSAlert</category>
                       </item><item>
                       <title>Savoir si deux strings sont égaux</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=17#a67</link>
                       <description>Deux strings sont égaux si leur contenu est identique.

La méthode sur un NSString est :

- (BOOL)isEqualToString:(NSString *)aString


Quand on sait que les deux objets sont des strings, mieux vaut utiliser une autre méthode, sur un NSObject :

- (BOOL)isEqual:(id)anObject

</description>
                       <content:encoded><![CDATA[<p>Deux strings sont égaux si leur contenu est identique.</p>

<p>La méthode sur un <code>NSString</code> est :</p>

<pre><code>- (BOOL)isEqualToString:(NSString *)aString
</code></pre>

<p>Quand on sait que les deux objets sont des strings, mieux vaut utiliser une autre méthode, sur un <code>NSObject</code> :</p>

<pre><code>- (BOOL)isEqual:(id)anObject
</code></pre>
]]></content:encoded>
                       <category>NSString</category>
                       </item><item>
                       <title>Afficher l'ordre de tri dans l'entête des colonnes</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=16#a63</link>
                       <description>Voici comment ajouter les petits triangles orientés dans l'en-tête des colonnes :

[tableView setIndicatorImage: (colOrderingIsReversed ?
                               [NSImage imageNamed:@"NSDescendingSortIndicator"] :
                               [NSImage imageNamed:@"NSAscendingSortIndicator"])
               inTableColumn: tableColumn];

</description>
                       <content:encoded><![CDATA[<p>Voici comment ajouter les petits triangles orientés dans l'en-tête des colonnes :</p>

<pre><code>[tableView setIndicatorImage: (colOrderingIsReversed ?
                               [NSImage imageNamed:@"NSDescendingSortIndicator"] :
                               [NSImage imageNamed:@"NSAscendingSortIndicator"])
               inTableColumn: tableColumn];
</code></pre>
]]></content:encoded>
                       <category>NSTableView</category>
                       </item><item>
                       <title>Implémenter le glisser-déposer sur un `NSTableView`</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=16#a64</link>
                       <description>Indiquer les types des données acceptés :

- (void)awakeFromNib {
    //...

    [tableView registerForDraggedTypes: [NSArray arrayWithObjects:NSURLPboardType, nil]];
}


Il faut ensuite implémenter deux méthodes du protocole NSTableDataSource.

Déterminer le type de glisser-déposer et l'emplacement d'arrivée pendant le glisser :

- (NSDragOperation)tableView:(NSTableView *)theTableView
                validateDrop:(id &lt;NSDraggingInfo&gt;)info
                 proposedRow:(int)row
       proposedDropOperation:(NSTableViewDropOperation)operation {

    [theTableView setDropRow:0 dropOperation:NSTableViewDropAbove]; // par exemple

    return NSDragOperationCopy;
}


Déterminer l'acceptation de l'objet déposé :

- (BOOL)tableView:(NSTableView *)theTableView
       acceptDrop:(id &lt;NSDraggingInfo&gt;)info
              row:(int)row
    dropOperation:(NSTableViewDropOperation)operation {

    // par exemple pour n'accepter qu'une URL

    NSURL *url = [NSURL URLFromPasteboard:[info draggingPasteboard]];

    if (url) {
        return YES;     
    } else {
        return NO;
    }
}

</description>
                       <content:encoded><![CDATA[<p>Indiquer les types des données acceptés :</p>

<pre><code>- (void)awakeFromNib {
    //...

    [tableView registerForDraggedTypes: [NSArray arrayWithObjects:NSURLPboardType, nil]];
}
</code></pre>

<p>Il faut ensuite implémenter deux méthodes du protocole <code>NSTableDataSource</code>.</p>

<p>Déterminer le type de glisser-déposer et l'emplacement d'arrivée pendant le glisser :</p>

<pre><code>- (NSDragOperation)tableView:(NSTableView *)theTableView
                validateDrop:(id &lt;NSDraggingInfo&gt;)info
                 proposedRow:(int)row
       proposedDropOperation:(NSTableViewDropOperation)operation {

    [theTableView setDropRow:0 dropOperation:NSTableViewDropAbove]; // par exemple

    return NSDragOperationCopy;
}
</code></pre>

<p>Déterminer l'acceptation de l'objet déposé :</p>

<pre><code>- (BOOL)tableView:(NSTableView *)theTableView
       acceptDrop:(id &lt;NSDraggingInfo&gt;)info
              row:(int)row
    dropOperation:(NSTableViewDropOperation)operation {

    // par exemple pour n'accepter qu'une URL

    NSURL *url = [NSURL URLFromPasteboard:[info draggingPasteboard]];

    if (url) {
        return YES;     
    } else {
        return NO;
    }
}
</code></pre>
]]></content:encoded>
                       <category>NSTableView</category>
                       </item><item>
                       <title>Réagir au clic sur l'en-tête d'une colonne</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=16#a65</link>
                       <description>// clic sur l'en-tête d'une colonne
- (void)  tableView:(NSTableView*)theTableView
didClickTableColumn:(NSTableColumn *)tableColumn {

    // inverser l'ordre de tri
    colOrderingIsReversed = !colOrderingIsReversed;

    // trier le tableau à l'aide des descripteurs de tri
    [records sortUsingDescriptors:descriptors];

    // mettre à jour la vue
    [tableView reloadData];
}

</description>
                       <content:encoded><![CDATA[<pre><code>// clic sur l'en-tête d'une colonne
- (void)  tableView:(NSTableView*)theTableView
didClickTableColumn:(NSTableColumn *)tableColumn {

    // inverser l'ordre de tri
    colOrderingIsReversed = !colOrderingIsReversed;

    // trier le tableau à l'aide des descripteurs de tri
    [records sortUsingDescriptors:descriptors];

    // mettre à jour la vue
    [tableView reloadData];
}
</code></pre>
]]></content:encoded>
                       <category>NSTableView</category>
                       </item><item>
                       <title>Réagir aux changements de sélection</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=16#a66</link>
                       <description>- (void) tableViewSelectionDidChange: (NSNotification *) notification {
    int row;
    row = [tableView selectedRow];

    if (row == -1) {
        // aucune colonne sélectionnée
    } else {
        // une ou plusieurs colonnes sélectionnées
    }   
}

</description>
                       <content:encoded><![CDATA[<pre><code>- (void) tableViewSelectionDidChange: (NSNotification *) notification {
    int row;
    row = [tableView selectedRow];

    if (row == -1) {
        // aucune colonne sélectionnée
    } else {
        // une ou plusieurs colonnes sélectionnées
    }   
}
</code></pre>
]]></content:encoded>
                       <category>NSTableView</category>
                       </item><item>
                       <title>Exécuter un script externe</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=40#a138</link>
                       <description>#import &lt;Foundation/Foundation.h&gt;

int main (int argc, const char * argv[]) {
&nbsp;&nbsp;&nbsp;&nbsp;NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

&nbsp;&nbsp;&nbsp;&nbsp;NSFileManager *fileManager = [NSFileManager defaultManager];

&nbsp;&nbsp;&nbsp;&nbsp;CFUUIDRef uuid = CFUUIDCreate(NULL);
&nbsp;&nbsp;&nbsp;&nbsp;NSString *uniqueString = (NSString *)CFUUIDCreateString(NULL, uuid);
&nbsp;&nbsp;&nbsp;&nbsp;CFRelease(uuid);
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;NSString *tempFile = [NSString pathWithComponents:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[NSArray arrayWithObjects: NSTemporaryDirectory(), uniqueString, nil]];
&nbsp;&nbsp;&nbsp;&nbsp;[fileManager createFileAtPath:tempFile contents:nil attributes:nil];
&nbsp;&nbsp;&nbsp;&nbsp;NSFileHandle *file = [NSFileHandle fileHandleForWritingAtPath:tempFile];
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;NSTask *task = [[NSTask alloc] init];
&nbsp;&nbsp;&nbsp;&nbsp;[task setLaunchPath:@"/usr/bin/perl"];
&nbsp;&nbsp;&nbsp;&nbsp;[task setArguments:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[NSArray arrayWithObjects:@"/Users/nst/bin/iso2txt",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@"/Users/nst/Desktop/asd.iso2709",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nil]];
&nbsp;&nbsp;&nbsp;&nbsp;[task setStandardOutput:file];
&nbsp;&nbsp;&nbsp;&nbsp;[task launch];
&nbsp;&nbsp;&nbsp;&nbsp;[task waitUntilExit];
&nbsp;&nbsp;&nbsp;&nbsp;[task release];
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;NSLog([NSString stringWithContentsOfFile:tempFile]);
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;[fileManager removeFileAtPath:tempFile handler:nil];

&nbsp;&nbsp;&nbsp;&nbsp;[pool release];
&nbsp;&nbsp;&nbsp;&nbsp;return 0;
}

</description>
                       <content:encoded><![CDATA[<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#683821;">#import &lt;Foundation/Foundation.h&gt;<br />
</span><br />
<span style="color:#881350;">int</span> <span style="color:#003369;">main </span>(<span style="color:#881350;">int</span> argc, <span style="color:#881350;">const</span> <span style="color:#881350;">char</span> * argv[]) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSAutoreleasePool</span> * pool = [[<span style="color:#400080;">NSAutoreleasePool</span> <span style="color:#ff0000;">alloc</span>] <span style="color:#6c0540;">init</span>];<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSFileManager</span> *fileManager = [<span style="color:#400080;">NSFileManager</span> <span style="color:#6c0540;">defaultManager</span>];<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;CFUUIDRef uuid = <span style="color:#003369;">CFUUIDCreate</span>(<span style="color:#881350;">NULL</span>);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSString</span> *uniqueString = (<span style="color:#400080;">NSString</span> *)<span style="color:#003369;">CFUUIDCreateString</span>(<span style="color:#881350;">NULL</span>, uuid);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#003369;">CFRelease</span>(uuid);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSString</span> *tempFile = [<span style="color:#400080;">NSString</span> <span style="color:#6c0540;">pathWithComponents:</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<span style="color:#400080;">NSArray</span> <span style="color:#6c0540;">arrayWithObjects:</span> <span style="color:#400080;">NSTemporaryDirectory</span>(), uniqueString, <span style="color:#881350;">nil</span>]];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[fileManager <span style="color:#6c0540;">createFileAtPath:</span>tempFile <span style="color:#6c0540;">contents:</span><span style="color:#881350;">nil</span> <span style="color:#6c0540;">attributes:</span><span style="color:#881350;">nil</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSFileHandle</span> *file = [<span style="color:#400080;">NSFileHandle</span> <span style="color:#6c0540;">fileHandleForWritingAtPath:</span>tempFile];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSTask</span> *task = [[<span style="color:#400080;">NSTask</span> <span style="color:#ff0000;">alloc</span>] <span style="color:#6c0540;">init</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[task <span style="color:#6c0540;">setLaunchPath:</span><span style="color:#760f15;">@"/usr/bin/perl"</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[task <span style="color:#6c0540;">setArguments:</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<span style="color:#400080;">NSArray</span> <span style="color:#6c0540;">arrayWithObjects:</span><span style="color:#760f15;">@"/Users/nst/bin/iso2txt"</span>,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#760f15;">@"/Users/nst/Desktop/asd.iso2709"</span>,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">nil</span>]];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[task <span style="color:#6c0540;">setStandardOutput:</span>file];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[task <span style="color:#6c0540;">launch</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[task <span style="color:#6c0540;">waitUntilExit</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[task <span style="color:#ff0000;">release</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSLog</span>([<span style="color:#400080;">NSString</span> <span style="color:#6c0540;">stringWithContentsOfFile:</span>tempFile]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;[fileManager <span style="color:#6c0540;">removeFileAtPath:</span>tempFile <span style="color:#6c0540;">handler:</span><span style="color:#881350;">nil</span>];<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;[pool <span style="color:#ff0000;">release</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">return</span> <span style="color:#0000ff;">0</span>;<br />
}<br />
</div>
]]></content:encoded>
                       <category>NSTask</category>
                       </item><item>
                       <title>Exécuter une méthode dans un nouveau thread</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=48#a210</link>
                       <description>- (void)doSomeWorkInThreadMethod:(id)anObject {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    // do thread work here
    [pool release];
}

[NSThread detachNewThreadSelector:@selector(doSomeWorkInThreadMethod:)
                         toTarget:myInstance
                       withObject:nil];

</description>
                       <content:encoded><![CDATA[<pre><code>- (void)doSomeWorkInThreadMethod:(id)anObject {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    // do thread work here
    [pool release];
}

[NSThread detachNewThreadSelector:@selector(doSomeWorkInThreadMethod:)
                         toTarget:myInstance
                       withObject:nil];
</code></pre>
]]></content:encoded>
                       <category>NSThread</category>
                       </item><item>
                       <title>Obtenir le thread courant</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=48#a218</link>
                       <description>[NSThread currentThread]

</description>
                       <content:encoded><![CDATA[<pre><code>[NSThread currentThread]
</code></pre>
]]></content:encoded>
                       <category>NSThread</category>
                       </item><item>
                       <title>Suspendre le thread courant</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=48#a168</link>
                       <description>Suspension de une seconde :

[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];

</description>
                       <content:encoded><![CDATA[<p>Suspension de une seconde :</p>

<pre><code>[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
</code></pre>
]]></content:encoded>
                       <category>NSThread</category>
                       </item><item>
                       <title>Utiliser un NSValueTransformer</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=24#a72</link>
                       <description>Une sous-classe de NSValueTransformer permet de modifier la présentation de données liées.

URLNameTransformer.h

#import &lt;Cocoa/Cocoa.h&gt;

@interface URLNameTransformer : NSValueTransformer {

}

+ (Class)transformedValueClass;
+ (BOOL)allowsReverseTransformation;
- (id)transformedValue:(id)value;

@end


URLNameTransformer.m

#import "URLNameTransformer.h"

@implementation URLNameTransformer

+ (Class)transformedValueClass {
    return [NSString class];
}

+ (BOOL)allowsReverseTransformation {
    return NO;
}

- (id)transformedValue:(id)value {
    if (value == nil) {
        return value;
    } else {
        NSURL *url = [NSURL URLWithString:(NSString *)value];
        return [url host];
    }
}

@end


Pour l'utiliser :


enregistrer le transformeur

- (void)awakeFromNib {
    URLNameTransformer *urlTrans = [[[URLNameTransformer alloc] init] autorelease];
    [NSValueTransformer setValueTransformer:urlTrans
                                    forName:@"URLNameTransformer"];
}

appeler le transformeur dans Interface Builder



</description>
                       <content:encoded><![CDATA[<p>Une sous-classe de <code>NSValueTransformer</code> permet de modifier la présentation de données liées.</p>

<p>URLNameTransformer.h</p>

<pre><code>#import &lt;Cocoa/Cocoa.h&gt;

@interface URLNameTransformer : NSValueTransformer {

}

+ (Class)transformedValueClass;
+ (BOOL)allowsReverseTransformation;
- (id)transformedValue:(id)value;

@end
</code></pre>

<p>URLNameTransformer.m</p>

<pre><code>#import "URLNameTransformer.h"

@implementation URLNameTransformer

+ (Class)transformedValueClass {
    return [NSString class];
}

+ (BOOL)allowsReverseTransformation {
    return NO;
}

- (id)transformedValue:(id)value {
    if (value == nil) {
        return value;
    } else {
        NSURL *url = [NSURL URLWithString:(NSString *)value];
        return [url host];
    }
}

@end
</code></pre>

<p>Pour l'utiliser :</p>

<ol>
<li><p>enregistrer le transformeur</p>

<pre><code>- (void)awakeFromNib {
    URLNameTransformer *urlTrans = [[[URLNameTransformer alloc] init] autorelease];
    [NSValueTransformer setValueTransformer:urlTrans
                                    forName:@"URLNameTransformer"];
}
</code></pre></li>
<li><p>appeler le transformeur dans Interface Builder</p>

<p><img src="http://quickies.seriot.ch/images/cocoa/NSValueTransformer.png" alt="NSValueTransformer" title="NSValueTransformer" /></p></li>
</ol>
]]></content:encoded>
                       <category>NSValueTransformer</category>
                       </item><item>
                       <title>Concaténer deux fichiers PDF</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=31#a109</link>
                       <description>Avec Ghostscript :

$ gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf a.pdf b.pdf

</description>
                       <content:encoded><![CDATA[<p>Avec Ghostscript :</p>

<pre><code>$ gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf a.pdf b.pdf
</code></pre>
]]></content:encoded>
                       <category>PDF</category>
                       </item><item>
                       <title>Spécifications du format PDF</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=31#a111</link>
                       <description>http://partners.adobe.com/public/developer/pdf/index_reference.html
</description>
                       <content:encoded><![CDATA[<p><a href="http://partners.adobe.com/public/developer/pdf/index_reference.html">http://partners.adobe.com/public/developer/pdf/index_reference.html</a></p>
]]></content:encoded>
                       <category>PDF</category>
                       </item><item>
                       <title>Supprimer le mot de passe 'owner' d'un fichier PDF</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=31#a110</link>
                       <description>$ java -classpath Multivalent20040415.jar tool.pdf.Decrypt file.pdf


Multivalent20040415.jar
</description>
                       <content:encoded><![CDATA[<pre><code>$ java -classpath Multivalent20040415.jar tool.pdf.Decrypt file.pdf
</code></pre>

<p><a href="http://prdownloads.sourceforge.net/multivalent/Multivalent20040415.jar?download">Multivalent20040415.jar</a></p>
]]></content:encoded>
                       <category>PDF</category>
                       </item><item>
                       <title>Dumper la structure d'une base</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=47#a205</link>
                       <description>$ pg_dump -s DB_NAME -t TABLE_NAME

</description>
                       <content:encoded><![CDATA[<pre><code>$ pg_dump -s DB_NAME -t TABLE_NAME
</code></pre>
]]></content:encoded>
                       <category>PosgreSQL</category>
                       </item><item>
                       <title>Lister les bases</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=47#a201</link>
                       <description>postgres=# \l

</description>
                       <content:encoded><![CDATA[<pre><code>postgres=# \l
</code></pre>
]]></content:encoded>
                       <category>PosgreSQL</category>
                       </item><item>
                       <title>Charger un framework Objective-C</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=34#a116</link>
                       <description>import objc

objc.loadBundle("InstantMessage", globals(),
                bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/InstantMessage.framework'))

service = IMService.serviceWithName_('AIM')
print service.peopleWithScreenName_('pikswiss')


Depuis Mac OS X 10.5 :

from AddressBook import *

book = ABAddressBook.sharedAddressBook()
print book.me()

</description>
                       <content:encoded><![CDATA[<pre><code>import objc

objc.loadBundle("InstantMessage", globals(),
                bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/InstantMessage.framework'))

service = IMService.serviceWithName_('AIM')
print service.peopleWithScreenName_('pikswiss')
</code></pre>

<p>Depuis Mac OS X 10.5 :</p>

<pre><code>from AddressBook import *

book = ABAddressBook.sharedAddressBook()
print book.me()
</code></pre>
]]></content:encoded>
                       <category>PyObjC</category>
                       </item><item>
                       <title>Afficher la date et l'heure</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a185</link>
                       <description>import locale
import datetime

locale.setlocale(locale.LC_ALL, 'fr_FR')
now = datetime.datetime.now()
now.strftime("%A %d %B %Y, %H:%M")
#'Samedi 20 janvier 2007, 15:17'


Autre possibilité

from time import strftime
strftime("%Y-%m-%d %H:%M:%S")
#'2008-09-28 20:33:09'

</description>
                       <content:encoded><![CDATA[<pre><code>import locale
import datetime

locale.setlocale(locale.LC_ALL, 'fr_FR')
now = datetime.datetime.now()
now.strftime("%A %d %B %Y, %H:%M")
#'Samedi 20 janvier 2007, 15:17'
</code></pre>

<p>Autre possibilité</p>

<pre><code>from time import strftime
strftime("%Y-%m-%d %H:%M:%S")
#'2008-09-28 20:33:09'
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Arithmétique sur le calendrier</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a202</link>
                       <description>&gt;&gt;&gt; import datetime

&gt;&gt;&gt; today = datetime.date.today()
&gt;&gt;&gt; today.replace(day=1)
datetime.date(2007, 2, 1)
&gt;&gt;&gt; today.replace(month=today.month+1).replace(day=1)
datetime.date(2007, 3, 1)

</description>
                       <content:encoded><![CDATA[<pre><code>&gt;&gt;&gt; import datetime

&gt;&gt;&gt; today = datetime.date.today()
&gt;&gt;&gt; today.replace(day=1)
datetime.date(2007, 2, 1)
&gt;&gt;&gt; today.replace(month=today.month+1).replace(day=1)
datetime.date(2007, 3, 1)
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Code Coverage</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a286</link>
                       <description>http://garethrees.org/2001/12/04/python-coverage/

Here with a Django project:

$ coverage.py -x manage.py test
$ coverage.py -a app/models.py
$ mate app/models.py,cover 

</description>
                       <content:encoded><![CDATA[<p>http://garethrees.org/2001/12/04/python-coverage/</p>

<p>Here with a Django project:</p>

<pre><code>$ coverage.py -x manage.py test
$ coverage.py -a app/models.py
$ mate app/models.py,cover 
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Code profiling</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a140</link>
                       <description>Faire exécuter le code par le profiler :

import hotshot

prof = hotshot.Profile("hotshot_stats")
prof.runcall(main_function)
prof.close()


Afficher les résultats :

from hotshot import stats

s = stats.load("hotshot_stats_file")
s.sort_stats("time").print_stats()

</description>
                       <content:encoded><![CDATA[<p>Faire exécuter le code par le profiler :</p>

<pre><code>import hotshot

prof = hotshot.Profile("hotshot_stats")
prof.runcall(main_function)
prof.close()
</code></pre>

<p>Afficher les résultats :</p>

<pre><code>from hotshot import stats

s = stats.load("hotshot_stats_file")
s.sort_stats("time").print_stats()
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Concaténer des strings</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a79</link>
                       <description>Utiliser cette expression qui prend un temps linéaire :

result = ''.join(strings)


plutôt que celle-ci qui prend un temps quadratique :

result = []
for s in strings:
    result += s

</description>
                       <content:encoded><![CDATA[<p>Utiliser cette expression qui prend un temps linéaire :</p>

<pre><code>result = ''.join(strings)
</code></pre>

<p>plutôt que celle-ci qui prend un temps quadratique :</p>

<pre><code>result = []
for s in strings:
    result += s
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Convertir un string utf-8 en latin-1</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a151</link>
                       <description>s_latin1 = unicode(s_utf8, 'utf-8').encode('latin-1', 'replace')

</description>
                       <content:encoded><![CDATA[<pre><code>s_latin1 = unicode(s_utf8, 'utf-8').encode('latin-1', 'replace')
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Datagrammes à travers des sockets</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a143</link>
                       <description>server.py

import socket

port = 8081
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("", port))
print "waiting on port:", port
while 1:
    data, addr = s.recvfrom(1024)
    print data


client.py

import socket

port = 8081
host = "localhost"
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("", 0))
s.sendto("Holy Guido! It's working.", (host, port))


Source : Jeff Bauer
</description>
                       <content:encoded><![CDATA[<p>server.py</p>

<pre><code>import socket

port = 8081
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("", port))
print "waiting on port:", port
while 1:
    data, addr = s.recvfrom(1024)
    print data
</code></pre>

<p>client.py</p>

<pre><code>import socket

port = 8081
host = "localhost"
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("", 0))
s.sendto("Holy Guido! It's working.", (host, port))
</code></pre>

<p>Source : <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52218">Jeff Bauer</a></p>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Detach new thread</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a276</link>
                       <description>#!/usr/bin/python

import thread
import time

def my_function():
&nbsp;&nbsp;&nbsp;&nbsp;while 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &quot;thread 2&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;time.sleep(0.6)

print &quot;-- will detach new thread&quot;
thread.start_new_thread(my_function, ())
print &quot;-- did detach new thread&quot;

while 1:
&nbsp;&nbsp;&nbsp;&nbsp;print &quot;thread 1&quot;
&nbsp;&nbsp;&nbsp;&nbsp;time.sleep(1)

</description>
                       <content:encoded><![CDATA[<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#236e25;">#!/usr/bin/python<br />
</span><br />
<span style="color:#881350;">import</span> thread<br />
<span style="color:#881350;">import</span> time<br />
<br />
<span style="color:#881350;">def</span> my_function():<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">while</span> <span style="color:#0000ff;">1</span>:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">print</span> <span style="color:#760f15;">&quot;thread 2&quot;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;time.sleep(<span style="color:#0000ff;">0.6</span>)<br />
<br />
<span style="color:#881350;">print</span> <span style="color:#760f15;">&quot;-- will detach new thread&quot;</span><br />
thread.start_new_thread(my_function, ())<br />
<span style="color:#881350;">print</span> <span style="color:#760f15;">&quot;-- did detach new thread&quot;</span><br />
<br />
<span style="color:#881350;">while</span> <span style="color:#0000ff;">1</span>:<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">print</span> <span style="color:#760f15;">&quot;thread 1&quot;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;time.sleep(<span style="color:#0000ff;">1</span>)<br />
</div>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Déterminer l'endianess</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a141</link>
                       <description>import sys

if sys.byteorder == "little":
    print "little-endian platform (intel, alpha)"
else:
    print "big-endian platform (motorola, sparc)"

</description>
                       <content:encoded><![CDATA[<pre><code>import sys

if sys.byteorder == "little":
    print "little-endian platform (intel, alpha)"
else:
    print "big-endian platform (motorola, sparc)"
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Envoyer un email</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a101</link>
                       <description>#!/usr/bin/python
# -*- coding: iso-8859-1 -*-

import smtplib
import time

from_addr = "tintin@bluewin.ch"
to_addrs &nbsp;= ["milou@vtx.ch"]
date = time.ctime(time.time())

msg = """From: "Georges W. Bush" &lt;bush@whitehouse.gov&gt;
Subject: Secret plan
Date: %s
To: "Donald Rumsfeld" &lt;rumsfeld@whitehouse.gov&gt;
X-Mailer: Apple Mail (2.733)

This is a test

&eacute; &agrave;
""" % date

s = smtplib.SMTP('smtp.bluewin.ch')

s.set_debuglevel(1)

s.sendmail(from_addr, to_addrs, msg)

s.quit()

</description>
                       <content:encoded><![CDATA[<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#236e25;">#!/usr/bin/python<br />
# -*- coding: iso-8859-1 -*-<br />
</span><br />
<span style="color:#881350;">import</span> smtplib<br />
<span style="color:#881350;">import</span> time<br />
<br />
from_addr = <span style="color:#760f15;">"tintin@bluewin.ch"</span><br />
to_addrs &nbsp;= [<span style="color:#760f15;">"milou@vtx.ch"</span>]<br />
date = time.ctime(time.time())<br />
<br />
msg = <span style="color:#760f15;">"""From: "Georges W. Bush" &lt;bush@whitehouse.gov&gt;<br />
Subject: Secret plan<br />
Date: %s<br />
To: "Donald Rumsfeld" &lt;rumsfeld@whitehouse.gov&gt;<br />
X-Mailer: Apple Mail (2.733)<br />
<br />
This is a test<br />
<br />
&eacute; &agrave;<br />
"""</span> % date<br />
<br />
s = smtplib.SMTP(<span style="color:#760f15;">'smtp.bluewin.ch'</span>)<br />
<br />
s.set_debuglevel(<span style="color:#0000ff;">1</span>)<br />
<br />
s.sendmail(from_addr, to_addrs, msg)<br />
<br />
s.quit()<br />
</div>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Find site-packages path</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a271</link>
                       <description>$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/Library/Python/2.5/site-packages

</description>
                       <content:encoded><![CDATA[<pre><code>$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/Library/Python/2.5/site-packages
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Gérer un timeout avec urllib</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a89</link>
                       <description>#!/usr/bin/python

import socket
from urllib import urlopen

socket.setdefaulttimeout(2) # secondes

try:
&nbsp;&nbsp;&nbsp;&nbsp;print urlopen("http://checkip.dyndns.org").readlines()
except IOError:
&nbsp;&nbsp;&nbsp;&nbsp;print "timeout"
</description>
                       <content:encoded><![CDATA[<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#236e25;">#!/usr/bin/python<br />
</span><br />
<span style="color:#881350;">import</span> socket<br />
<span style="color:#881350;">from</span> urllib <span style="color:#881350;">import</span> urlopen<br />
<br />
socket.setdefaulttimeout(<span style="color:#0000ff;">2</span>) <span style="color:#236e25;"># secondes<br />
</span><br />
<span style="color:#881350;">try</span>:<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">print</span> urlopen(<span style="color:#760f15;">"http://checkip.dyndns.org"</span>).readlines()<br />
<span style="color:#881350;">except</span> <span style="color:#f79600;">IOError</span>:<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">print</span> <span style="color:#760f15;">"timeout"</span></div>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Get self IP address</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a275</link>
                       <description>import socket
print socket.gethostbyname(socket.gethostname())


192.168.0.231
</description>
                       <content:encoded><![CDATA[<pre><code>import socket
print socket.gethostbyname(socket.gethostname())
</code></pre>

<p>192.168.0.231</p>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Kill current process</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a278</link>
                       <description>#!/usr/bin/python

import os

print "-- will kill"
pid = os.getpid()
print "-- pid:", pid
os.kill(pid, 1)
print "-- did kill"

</description>
                       <content:encoded><![CDATA[<pre><code>#!/usr/bin/python

import os

print "-- will kill"
pid = os.getpid()
print "-- pid:", pid
os.kill(pid, 1)
print "-- did kill"
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Mapper un ensemble de caractères sur un autre</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a145</link>
                       <description># -*- coding: iso-8859-1 -*-

import string

french = "Peut-être cet été à la mer."

char_from = "éêà"
char_to   = "eea"

print french.translate(string.maketrans(char_from,char_to))


Peut-etre cet ete a la mer.
</description>
                       <content:encoded><![CDATA[<pre><code># -*- coding: iso-8859-1 -*-

import string

french = "Peut-être cet été à la mer."

char_from = "éêà"
char_to   = "eea"

print french.translate(string.maketrans(char_from,char_to))
</code></pre>

<p><code>Peut-etre cet ete a la mer.</code></p>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Méthodes de classe</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a237</link>
                       <description>class C:

    def foo(cls, y):
        print "classmethod", cls, y
    foo = classmethod(foo)

C.foo(1)
c = C()
c.foo(1)


Unifying types and classes in Python 2.2
</description>
                       <content:encoded><![CDATA[<pre><code>class C:

    def foo(cls, y):
        print "classmethod", cls, y
    foo = classmethod(foo)

C.foo(1)
c = C()
c.foo(1)
</code></pre>

<p><a href="http://www.python.org/download/releases/2.2/descrintro/#staticmethods">Unifying types and classes in Python 2.2</a></p>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Méthodes statiques</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a236</link>
                       <description>class C:

    def foo(x, y):
        print "staticmethod", x, y
    foo = staticmethod(foo)

C.foo(1, 2)
c = C()
c.foo(1, 2)


Unifying types and classes in Python 2.2
</description>
                       <content:encoded><![CDATA[<pre><code>class C:

    def foo(x, y):
        print "staticmethod", x, y
    foo = staticmethod(foo)

C.foo(1, 2)
c = C()
c.foo(1, 2)
</code></pre>

<p><a href="http://www.python.org/download/releases/2.2/descrintro/#staticmethods">Unifying types and classes in Python 2.2</a></p>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Pretty print JSON</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a291</link>
                       <description>$ echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool


http://stackoverflow.com/questions/352098/how-to-pretty-print-json-script
</description>
                       <content:encoded><![CDATA[<pre><code>$ echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool
</code></pre>

<p>http://stackoverflow.com/questions/352098/how-to-pretty-print-json-script</p>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Récupérer le résultat d'une commande du shell</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a206</link>
                       <description>import popen2
(stdout, stdin, stderr) = popen2.popen3("ping -q -c2 www.google.com")
print stdout.readlines()

</description>
                       <content:encoded><![CDATA[<pre><code>import popen2
(stdout, stdin, stderr) = popen2.popen3("ping -q -c2 www.google.com")
print stdout.readlines()
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Récupérer les variables d'environnement</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a227</link>
                       <description>import os

for param in os.environ.keys():
    print "%20s %s" % (param,os.environ[param])

</description>
                       <content:encoded><![CDATA[<pre><code>import os

for param in os.environ.keys():
    print "%20s %s" % (param,os.environ[param])
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Remplacements multiples en une seule passe</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a103</link>
                       <description>import re

def strTr( text, dic ):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;""" Replaces keys of dic with values of dic in text.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2005-02 by Emanuel Rumpf """
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pat = "(%s)" % "|".join( map(re.escape, dic.keys()) &nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return re.sub( pat, lambda m:dic[m.group()], text )

</description>
                       <content:encoded><![CDATA[<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#881350;">import</span> re<br />
<br />
<span style="color:#881350;">def</span> strTr( text, dic ):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#760f15;">""" Replaces keys of dic with values of dic in text.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2005-02 by Emanuel Rumpf """</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pat = <span style="color:#760f15;">"(%s)"</span> % <span style="color:#760f15;">"|"</span>.join( <span style="color:#440088;">map</span>(re.escape, dic.keys()) &nbsp;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">return</span> re.sub( pat, <span style="color:#881350;">lambda</span> m:dic[m.group()], text )<br />
</div>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Singleton</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a144</link>
                       <description>class Singleton:
    __shared_state = {}
    def __init__(self):
        self.__dict__ = self.__shared_state


D'après Alex Martelli

Cette classe peut être instanciée plusieurs fois, mais toutes les instances partagent le même êtat.

class Singleton(object):
    def __new__(type):
        if not '_the_instance' in type.__dict__:
            type._the_instance = object.__new__(type)
        return type._the_instance


Cette classe retourne la même instance à chaque instanciation.
</description>
                       <content:encoded><![CDATA[<pre><code>class Singleton:
    __shared_state = {}
    def __init__(self):
        self.__dict__ = self.__shared_state
</code></pre>

<p>D'après <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531">Alex Martelli</a></p>

<p>Cette classe peut être instanciée plusieurs fois, mais toutes les instances partagent le même êtat.</p>

<pre><code>class Singleton(object):
    def __new__(type):
        if not '_the_instance' in type.__dict__:
            type._the_instance = object.__new__(type)
        return type._the_instance
</code></pre>

<p>Cette classe retourne la même instance à chaque instanciation.</p>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Supprimer le HTML</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a139</link>
                       <description>import sgmllib

class Stripper(sgmllib.SGMLParser):
&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sgmllib.SGMLParser.__init__(self)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;def strip(self, some_html):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.theString = ""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.feed(some_html)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.close()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return self.theString
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;def handle_data(self, data):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.theString += data

stripper = Stripper()
print stripper.strip("&lt;tag&gt;asd&lt;/tag&gt;")

</description>
                       <content:encoded><![CDATA[<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#881350;">import</span> sgmllib<br />
<br />
<span style="color:#881350;">class</span> Stripper(sgmllib.SGMLParser):<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">def</span> <span style="color:#ff0000;">__init__</span>(<span style="color:#881350;">self</span>):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sgmllib.SGMLParser.<span style="color:#ff0000;">__init__</span>(<span style="color:#881350;">self</span>)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">def</span> strip(<span style="color:#881350;">self</span>, some_html):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">self</span>.theString = <span style="color:#760f15;">""</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">self</span>.feed(some_html)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">self</span>.close()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">return</span> <span style="color:#881350;">self</span>.theString<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">def</span> handle_data(<span style="color:#881350;">self</span>, data):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">self</span>.theString += data<br />
<br />
stripper = Stripper()<br />
<span style="color:#881350;">print</span> stripper.strip(<span style="color:#760f15;">"&lt;tag&gt;asd&lt;/tag&gt;"</span>)<br />
</div>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>The Zen of Python</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a130</link>
                       <description>&gt;&gt;&gt; import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

</description>
                       <content:encoded><![CDATA[<pre><code>&gt;&gt;&gt; import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Une classe simple pour démarrer rapidement</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a9</link>
                       <description>#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
__version__ = "$Revision: 0.1 $"
__author__ = "Nicolas Seriot"
__date__ = "2005-03-27"

import re # pour l'exemple

class Voiture:
    """
    Cette classe représente une voiture
    """
    
    __marque  = ""
    __couleur = ""
    
    # constructeur
    def __init__(self, marque, couleur):        
        self.__marque  = marque
        self.__couleur = couleur
    
    # une méthode
    def repeindre(self, couleur):
        self.__couleur = couleur
    
    # affichage
    def __str__(self):
        return self.__marque + ", " + self.__couleur
    
    # destructeur
    def __del__(self):
        pass
        
if __name__ == "__main__":
    
    v1 = Voiture("Peugeot", "bleu")
    v2 = Voiture("Renault", "vert")
    
    garage = [v1, v2]
    
    v2.repeindre("rouge")
    
    for v in garage:
        print v


$ python Voiture.py
Peugeot, bleu
Renault, rouge

</description>
                       <content:encoded><![CDATA[<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#236e25;">#!/usr/bin/python<br />
# -*- coding: iso-8859-1 -*-<br />
</span>__version__ = <span style="color:#760f15;">"$Revision: 0.1 $"</span><br />
__author__ = <span style="color:#760f15;">"Nicolas Seriot"</span><br />
__date__ = <span style="color:#760f15;">"2005-03-27"</span><br />
<br />
<span style="color:#881350;">import</span> re <span style="color:#236e25;"># pour l'exemple<br />
</span><br />
<span style="color:#881350;">class</span> Voiture:<br />
    <span style="color:#760f15;">"""<br />
    Cette classe représente une voiture<br />
    """</span><br />
    <br />
    __marque  = <span style="color:#760f15;">""</span><br />
    __couleur = <span style="color:#760f15;">""</span><br />
    <br />
    <span style="color:#236e25;"># constructeur<br />
</span>    <span style="color:#881350;">def</span> <span style="color:#ff0000;">__init__</span>(<span style="color:#881350;">self</span>, marque, couleur):        <br />
        <span style="color:#881350;">self</span>.__marque  = marque<br />
        <span style="color:#881350;">self</span>.__couleur = couleur<br />
    <br />
    <span style="color:#236e25;"># une méthode<br />
</span>    <span style="color:#881350;">def</span> repeindre(<span style="color:#881350;">self</span>, couleur):<br />
        <span style="color:#881350;">self</span>.__couleur = couleur<br />
    <br />
    <span style="color:#236e25;"># affichage<br />
</span>    <span style="color:#881350;">def</span> <span style="color:#ff0000;">__str__</span>(<span style="color:#881350;">self</span>):<br />
        <span style="color:#881350;">return</span> <span style="color:#881350;">self</span>.__marque + <span style="color:#760f15;">", "</span> + <span style="color:#881350;">self</span>.__couleur<br />
    <br />
    <span style="color:#236e25;"># destructeur<br />
</span>    <span style="color:#881350;">def</span> <span style="color:#ff0000;">__del__</span>(<span style="color:#881350;">self</span>):<br />
        <span style="color:#881350;">pass</span><br />
        <br />
<span style="color:#881350;">if</span> __name__ == <span style="color:#760f15;">"__main__"</span>:<br />
    <br />
    v1 = Voiture(<span style="color:#760f15;">"Peugeot"</span>, <span style="color:#760f15;">"bleu"</span>)<br />
    v2 = Voiture(<span style="color:#760f15;">"Renault"</span>, <span style="color:#760f15;">"vert"</span>)<br />
    <br />
    garage = [v1, v2]<br />
    <br />
    v2.repeindre(<span style="color:#760f15;">"rouge"</span>)<br />
    <br />
    <span style="color:#881350;">for</span> v <span style="color:#881350;">in</span> garage:<br />
        <span style="color:#881350;">print</span> v<br />
</div>

<pre><code>$ python Voiture.py
Peugeot, bleu
Renault, rouge
</code></pre>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Use named pipes</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a277</link>
                       <description>#!/usr/bin/python

from subprocess import *
import os

FIFO_PATH = '/tmp/my_fifo'

if os.path.exists(FIFO_PATH):
&nbsp;&nbsp;&nbsp;&nbsp;os.unlink(FIFO_PATH)

if not os.path.exists(FIFO_PATH):
&nbsp;&nbsp;&nbsp;&nbsp;os.mkfifo(FIFO_PATH)
&nbsp;&nbsp;&nbsp;&nbsp;my_fifo = open(FIFO_PATH, 'w+')
&nbsp;&nbsp;&nbsp;&nbsp;print &quot;my_fifo:&quot;, my_fifo

pipe = Popen('/bin/date', shell=False, stdin=PIPE, stdout=my_fifo, stderr=PIPE)

print open(FIFO_PATH, 'r').readline()

os.unlink(FIFO_PATH)

</description>
                       <content:encoded><![CDATA[<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#236e25;">#!/usr/bin/python<br />
</span><br />
<span style="color:#881350;">from</span> subprocess <span style="color:#881350;">import</span> *<br />
<span style="color:#881350;">import</span> os<br />
<br />
FIFO_PATH = <span style="color:#760f15;">'/tmp/my_fifo'</span><br />
<br />
<span style="color:#881350;">if</span> os.path.exists(FIFO_PATH):<br />
&nbsp;&nbsp;&nbsp;&nbsp;os.unlink(FIFO_PATH)<br />
<br />
<span style="color:#881350;">if</span> <span style="color:#881350;">not</span> os.path.exists(FIFO_PATH):<br />
&nbsp;&nbsp;&nbsp;&nbsp;os.mkfifo(FIFO_PATH)<br />
&nbsp;&nbsp;&nbsp;&nbsp;my_fifo = <span style="color:#440088;">open</span>(FIFO_PATH, <span style="color:#760f15;">'w+'</span>)<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">print</span> <span style="color:#760f15;">&quot;my_fifo:&quot;</span>, my_fifo<br />
<br />
pipe = Popen(<span style="color:#760f15;">'/bin/date'</span>, shell=<span style="color:#881350;">False</span>, stdin=PIPE, stdout=my_fifo, stderr=PIPE)<br />
<br />
<span style="color:#881350;">print</span> <span style="color:#440088;">open</span>(FIFO_PATH, <span style="color:#760f15;">'r'</span>).readline()<br />
<br />
os.unlink(FIFO_PATH)<br />
</div>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Utiliser un Web Service</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=2#a102</link>
                       <description>Côté serveur :

#!/usr/bin/python

from SimpleXMLRPCServer import *

class My_Web_Service:
&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass

&nbsp;&nbsp;&nbsp;&nbsp;# not callable through XML RPC because starts with '_'
&nbsp;&nbsp;&nbsp;&nbsp;def _private(self):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;def add(self, x, y):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return x + y

&nbsp;&nbsp;&nbsp;&nbsp;def mul(self, x, y):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return x * y

if __name__ == "__main__":
&nbsp;&nbsp;&nbsp;&nbsp;server = SimpleXMLRPCServer(("localhost", 8080))
&nbsp;&nbsp;&nbsp;&nbsp;server.register_instance(My_Web_Service())
&nbsp;&nbsp;&nbsp;&nbsp;server.serve_forever()

Côté client :

#!/usr/bin/python

import xmlrpclib

server = xmlrpclib.Server('http://localhost:8080')

print server.add(3, 4)
print server.mul(3, 4)

</description>
                       <content:encoded><![CDATA[<p>Côté serveur :</p>

<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#236e25;">#!/usr/bin/python<br />
</span><br />
<span style="color:#881350;">from</span> SimpleXMLRPCServer <span style="color:#881350;">import</span> *<br />
<br />
<span style="color:#881350;">class</span> My_Web_Service:<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">def</span> <span style="color:#ff0000;">__init__</span>(<span style="color:#881350;">self</span>):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">pass</span><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;"># not callable through XML RPC because starts with '_'<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">def</span> _private(<span style="color:#881350;">self</span>):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">pass</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">def</span> add(<span style="color:#881350;">self</span>, x, y):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">return</span> x + y<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">def</span> mul(<span style="color:#881350;">self</span>, x, y):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">return</span> x * y<br />
<br />
<span style="color:#881350;">if</span> __name__ == <span style="color:#760f15;">"__main__"</span>:<br />
&nbsp;&nbsp;&nbsp;&nbsp;server = SimpleXMLRPCServer((<span style="color:#760f15;">"localhost"</span>, <span style="color:#0000ff;">8080</span>))<br />
&nbsp;&nbsp;&nbsp;&nbsp;server.register_instance(My_Web_Service())<br />
&nbsp;&nbsp;&nbsp;&nbsp;server.serve_forever()</div>

<p>Côté client :</p>

<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#236e25;">#!/usr/bin/python<br />
</span><br />
<span style="color:#881350;">import</span> xmlrpclib<br />
<br />
server = xmlrpclib.Server(<span style="color:#760f15;">'http://localhost:8080'</span>)<br />
<br />
<span style="color:#881350;">print</span> server.add(<span style="color:#0000ff;">3</span>, <span style="color:#0000ff;">4</span>)<br />
<span style="color:#881350;">print</span> server.mul(<span style="color:#0000ff;">3</span>, <span style="color:#0000ff;">4</span>)<br />
</div>
]]></content:encoded>
                       <category>Python</category>
                       </item><item>
                       <title>Install a package from source</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=53#a272</link>
                       <description>$ R CMD INSTALL PACKAGE_NAME
</description>
                       <content:encoded><![CDATA[<p>$ R CMD INSTALL PACKAGE_NAME</p>
]]></content:encoded>
                       <category>R</category>
                       </item><item>
                       <title>Afficher le menu debug</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a169</link>
                       <description>$ defaults write com.apple.Safari IncludeDebugMenu YES

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.Safari IncludeDebugMenu YES
</code></pre>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Bloquer les publicités</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a174</link>
                       <description>Télécharger une feuille de style comme celle-ci :codepoerty.net puis la désigner depuis Safari / Préférences / Avancées / Feuille de style.

Vous pouvez créer vos règles en vous inspirant de http://texturizer.net/firefox/adblock.html.
</description>
                       <content:encoded><![CDATA[<p>Télécharger une feuille de style comme celle-ci :<a href="http://www.codepoetry.net/userContent.css">codepoerty.net</a> puis la désigner depuis Safari / Préférences / Avancées / Feuille de style.</p>

<p>Vous pouvez créer vos règles en vous inspirant de <a href="http://texturizer.net/firefox/adblock.html">http://texturizer.net/firefox/adblock.html</a>.</p>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Change Safari history memory</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a250</link>
                       <description>$ defaults write com.apple.Safari WebKitHistoryItemLimit 2000
$ defaults write com.apple.Safari WebKitHistoryAgeInDaysLimit 30

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.Safari WebKitHistoryItemLimit 2000
$ defaults write com.apple.Safari WebKitHistoryAgeInDaysLimit 30
</code></pre>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Empêcher Safari de lire les PDF</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a178</link>
                       <description>$ defaults write com.apple.Safari WebKitOmitPDFSupport -bool YES

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.Safari WebKitOmitPDFSupport -bool YES
</code></pre>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Faire un lien sur une page man</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a173</link>
                       <description>Faire un lien sur une page man

On peut créer des liens vers des pages man, qui s'ouvriront dans le terminal.

Exemple, pour la page man de 'ls' : x-man-page://ls.
</description>
                       <content:encoded><![CDATA[<p>Faire un lien sur une page man</p>

<p>On peut créer des liens vers des pages man, qui s'ouvriront dans le terminal.</p>

<p>Exemple, pour la page man de 'ls' : <a href="x-man-page://ls">x-man-page://ls</a>.</p>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>FAQ développeur de Safari</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a177</link>
                       <description>http://developer.apple.com/internet/safari_faq.html
</description>
                       <content:encoded><![CDATA[<p><a href="http://developer.apple.com/internet/safari_faq.html">http://developer.apple.com/internet/safari_faq.html</a></p>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Importer les signets d'Explorer</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a175</link>
                       <description>L'importation ne s'effectue que lors du premier lancement.
Pour qu'elle soit réeffectuée, quittez Safari, utilisez la commande suivante et relancez Safari :

$ defaults write com.apple.Safari IEFavoritesWereImported No

</description>
                       <content:encoded><![CDATA[<p>L'importation ne s'effectue que lors du premier lancement.
Pour qu'elle soit réeffectuée, quittez Safari, utilisez la commande suivante et relancez Safari :</p>

<pre><code>$ defaults write com.apple.Safari IEFavoritesWereImported No
</code></pre>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Les raccourcis clavier de Safari...</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a171</link>
                       <description>... sont recensés dans le fichier /Applications/Safari.app/Contents/Resources/Shortcuts.html
</description>
                       <content:encoded><![CDATA[<p>... sont recensés dans le fichier /Applications/Safari.app/Contents/Resources/Shortcuts.html</p>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Ombrer un texte</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a172</link>
                       <description>Pour créer un effet d'ombre, il faut utilise la propriété text-shadow : voir les détails sur w3.org.
</description>
                       <content:encoded><![CDATA[<p>Pour créer un effet d'ombre, il faut utilise la propriété <code>text-shadow</code> : voir les détails sur <a href="http://www.w3.org/TR/CSS2/text.html#propdef-text-shadow">w3.org</a>.</p>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Ouvrir une URL dans une nouvelle fenêtre / nouvel onglet</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a176</link>
                       <description>À la place des commandes habituelles, on peut aussi taper une adresse puis faire pomme-enter.
</description>
                       <content:encoded><![CDATA[<p>À la place des commandes habituelles, on peut aussi taper une adresse puis faire pomme-enter.</p>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Safari 3: Display the Web Inspector</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a230</link>
                       <description>$ defaults write com.apple.Safari WebKitDeveloperExtras -bool true


See webkit.org.
</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.Safari WebKitDeveloperExtras -bool true
</code></pre>

<p>See <a href="http://webkit.org/blog/?p=41">webkit.org</a>.</p>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Télécharger plusieurs URLs</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=43#a170</link>
                       <description>Copier-coller des adresses dans la fenêtre des téléchargements (cmd-alt-L)
</description>
                       <content:encoded><![CDATA[<p>Copier-coller des adresses dans la fenêtre des téléchargements (cmd-alt-L)</p>
]]></content:encoded>
                       <category>Safari</category>
                       </item><item>
                       <title>Afficher l'espace disque disponible</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a179</link>
                       <description>$ df -k

</description>
                       <content:encoded><![CDATA[<pre><code>$ df -k
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Afficher les librairies liées par un binaire</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a211</link>
                       <description>$ otool -L /Users/nst/Desktop/InstrumentServer.app/Contents/MacOS/InstrumentServer 
/Users/nst/Desktop/InstrumentServer.app/Contents/MacOS/InstrumentServer:
        /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0)
        @executable_path/../Frameworks/NostromoSeries.framework/Versions/A/NostromoSeries (compatibility version 1.0.0, current version 1.0.0)
        @executable_path/../Frameworks/SenCC.framework/Versions/A/SenCC (compatibility version 1.0.0, current version 1.0.0)
        /Library/Frameworks/Python.framework/Versions/2.5/Python (compatibility version 2.5.0, current version 2.5.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.3)

</description>
                       <content:encoded><![CDATA[<pre><code>$ otool -L /Users/nst/Desktop/InstrumentServer.app/Contents/MacOS/InstrumentServer 
/Users/nst/Desktop/InstrumentServer.app/Contents/MacOS/InstrumentServer:
        /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0)
        @executable_path/../Frameworks/NostromoSeries.framework/Versions/A/NostromoSeries (compatibility version 1.0.0, current version 1.0.0)
        @executable_path/../Frameworks/SenCC.framework/Versions/A/SenCC (compatibility version 1.0.0, current version 1.0.0)
        /Library/Frameworks/Python.framework/Versions/2.5/Python (compatibility version 2.5.0, current version 2.5.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.3)
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>bz2</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a273</link>
                       <description>$ tar cjvf my_dir.tar.bz2 my_dir
$ tar xjvf my_dir.tar.bz2

</description>
                       <content:encoded><![CDATA[<pre><code>$ tar cjvf my_dir.tar.bz2 my_dir
$ tar xjvf my_dir.tar.bz2
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Changer l'encodage d'un texte</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a180</link>
                       <description>$ iconv -c -f UTF-8 -t LATIN1 utf8.txt &gt; latin1.txt

</description>
                       <content:encoded><![CDATA[<pre><code>$ iconv -c -f UTF-8 -t LATIN1 utf8.txt &gt; latin1.txt
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Check file integrity with SHA1 checksum</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a233</link>
                       <description>$ openssl sha1 my_image.dmg

</description>
                       <content:encoded><![CDATA[<pre><code>$ openssl sha1 my_image.dmg
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Chercher et afficher récursivement les noms des fichiers qui contiennent un string donné</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a208</link>
                       <description>$ grep "$1" * -Ri


Très pratique à utiliser en aliasant cette commande avec ffind:

alias fffind="grep $1 * -Ri"

</description>
                       <content:encoded><![CDATA[<pre><code>$ grep "$1" * -Ri
</code></pre>

<p>Très pratique à utiliser en aliasant cette commande avec <code>ffind</code>:</p>

<pre><code>alias fffind="grep $1 * -Ri"
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Compter le nombre de lignes d'un projet</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a190</link>
                       <description>Ici le nombre de lignes de fichier *.py

$ wc -l `find . -name "*.py" | awk '{print $1}'`

</description>
                       <content:encoded><![CDATA[<p>Ici le nombre de lignes de fichier *.py</p>

<pre><code>$ wc -l `find . -name "*.py" | awk '{print $1}'`
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>convertir des majuscules en minuscules</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a80</link>
                       <description>$ tr '[:upper:]' '[:lower:]' &lt; $1 &gt; $2

</description>
                       <content:encoded><![CDATA[<pre><code>$ tr '[:upper:]' '[:lower:]' &lt; $1 &gt; $2
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Découper et recomposer un fichier</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a148</link>
                       <description>En blocs de 15 lignes :

$ split -l 15 text_file.txt text_file
$ cat text_file* &gt; text_file.txt


En blocs de 5 Mo :

$ split -b 5m binary_file
$ cat binary_file* &gt; binary_file

</description>
                       <content:encoded><![CDATA[<p>En blocs de 15 lignes :</p>

<pre><code>$ split -l 15 text_file.txt text_file
$ cat text_file* &gt; text_file.txt
</code></pre>

<p>En blocs de 5 Mo :</p>

<pre><code>$ split -b 5m binary_file
$ cat binary_file* &gt; binary_file
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Démarrer en mode verbose</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a181</link>
                       <description># nvram boot-args="-v"

</description>
                       <content:encoded><![CDATA[<pre><code># nvram boot-args="-v"
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Exécuter un programme en tâche de fond</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a137</link>
                       <description>$ my_program &gt; out.txt 2&gt;&amp;1 &amp;

</description>
                       <content:encoded><![CDATA[<pre><code>$ my_program &gt; out.txt 2&gt;&amp;1 &amp;
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Générer un fichier de 128 kilobytes aléatoires</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a123</link>
                       <description>$ dd if=/dev/urandom of=random.dat bs=1k count=128

</description>
                       <content:encoded><![CDATA[<pre><code>$ dd if=/dev/urandom of=random.dat bs=1k count=128
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Générer un fichier HTML coloré selon la syntaxe d'un langage</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a142</link>
                       <description>$ enscript --color --language=html -Epython --output=file.html file.py

</description>
                       <content:encoded><![CDATA[<pre><code>$ enscript --color --language=html -Epython --output=file.html file.py
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>List most frequently used commands</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a259</link>
                       <description>$ history|awk '{a[$2]++ }END{for(i in a){print a[i]" "i}}'|sort -rn|head
159 svn
112 rm
53 cd
38 python2.5
26 open
12 ls
9 python
7 pdflatex
6 whois
6 locate

</description>
                       <content:encoded><![CDATA[<pre><code>$ history|awk '{a[$2]++ }END{for(i in a){print a[i]" "i}}'|sort -rn|head
159 svn
112 rm
53 cd
38 python2.5
26 open
12 ls
9 python
7 pdflatex
6 whois
6 locate
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>locate</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a166</link>
                       <description>La commande locate permet d'indexer les fichiers dans une base de données et d'effectuer des recherches dans cette base.

La base de donnée est /var/db/locate.database et se met à jour à l'aide du script/usr/libexec/locate.updatedb.

C'est à dire que pour mettre à jour la base et chercher les fichiers contenant le mot "rapport" par exemple, le procédé est le suivant:

$ sudo /usr/libexec/locate.updatedb
$ locate rapport

</description>
                       <content:encoded><![CDATA[<p>La commande locate permet d'indexer les fichiers dans une base de données et d'effectuer des recherches dans cette base.</p>

<p>La base de donnée est <code>/var/db/locate.database</code> et se met à jour à l'aide du script<code>/usr/libexec/locate.updatedb</code>.</p>

<p>C'est à dire que pour mettre à jour la base et chercher les fichiers contenant le mot "rapport" par exemple, le procédé est le suivant:</p>

<pre><code>$ sudo /usr/libexec/locate.updatedb
$ locate rapport
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Modifier le chemin d'une librairie liée</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a212</link>
                       <description>$ install_name_tool -change libbz2.1.0.2.dylib @executable_path/../Frameworks/libbz2.1.0.2.dylib MyFunBinary 

</description>
                       <content:encoded><![CDATA[<pre><code>$ install_name_tool -change libbz2.1.0.2.dylib @executable_path/../Frameworks/libbz2.1.0.2.dylib MyFunBinary 
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Rechercher tous les fichiers d'après leur nom</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a117</link>
                       <description>$ find . -name "*.txt" -print

</description>
                       <content:encoded><![CDATA[<pre><code>$ find . -name "*.txt" -print
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Rechercher tous les fichiers qui contiennent une chaîne donnée</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a118</link>
                       <description>$ find . -exec grep "my_string" '{}' \; -print

</description>
                       <content:encoded><![CDATA[<pre><code>$ find . -exec grep "my_string" '{}' \; -print
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Redirect stdin and stdout in a file</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a289</link>
                       <description>./xxx &gt;&gt; xxx.logs 2&gt;&amp;1

</description>
                       <content:encoded><![CDATA[<pre><code>./xxx &gt;&gt; xxx.logs 2&gt;&amp;1
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Spotlight search from command-line</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a229</link>
                       <description>Can replace unix find:

$ mdfind -onlyin ~/Documents Leopard

</description>
                       <content:encoded><![CDATA[<p>Can replace unix find:</p>

<pre><code>$ mdfind -onlyin ~/Documents Leopard
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>SSH sans mot de passe</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a132</link>
                       <description>Sur la machine locale

Générer les clés (sans indiquer de passphrase) :

$ ssh-keygen -t rsa


Copier la clé publique sur le serveur

$ scp ~/.ssh/id_rsa.pub nst@10.0.1.2:~/new_key


Sur la machine distante

$ cat ~/new_key &gt;&gt; ~/.ssh/authorized_keys 
$ rm new_key

</description>
                       <content:encoded><![CDATA[<p><strong>Sur la machine locale</strong></p>

<p>Générer les clés (sans indiquer de passphrase) :</p>

<pre><code>$ ssh-keygen -t rsa
</code></pre>

<p>Copier la clé publique sur le serveur</p>

<pre><code>$ scp ~/.ssh/id_rsa.pub nst@10.0.1.2:~/new_key
</code></pre>

<p><strong>Sur la machine distante</strong></p>

<pre><code>$ cat ~/new_key &gt;&gt; ~/.ssh/authorized_keys 
$ rm new_key
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>traffic shaping</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a262</link>
                       <description>slow down traffic with apple.com

sudo ipfw pipe 1 config bw 40kbit/s
sudo ipfw add pipe 1 src-ip 17.149.160.49
sudo ipfw add pipe 1 dst-ip 17.149.160.49


delete rules

sudo ipfw flush


Thanks Cédric for this great tip!

See also: Traffic Shaping in Mac OS X
</description>
                       <content:encoded><![CDATA[<p>slow down traffic with apple.com</p>

<pre><code>sudo ipfw pipe 1 config bw 40kbit/s
sudo ipfw add pipe 1 src-ip 17.149.160.49
sudo ipfw add pipe 1 dst-ip 17.149.160.49
</code></pre>

<p>delete rules</p>

<pre><code>sudo ipfw flush
</code></pre>

<p>Thanks <a href="http://0xced.blogspot.com">Cédric</a> for this great tip!</p>

<p>See also: <a href="http://www.macgeekery.com/hacks/software/traffic_shaping_in_mac_os_x">Traffic Shaping in Mac OS X</a></p>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Utiliser SSH dans un script shell</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a150</link>
                       <description>ssh stb@192.168.0.210 &lt;&lt;EOT
touch test_file
EOT
exit 0

</description>
                       <content:encoded><![CDATA[<pre><code>ssh stb@192.168.0.210 &lt;&lt;EOT
touch test_file
EOT
exit 0
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Zipper tous les fichiers texte d'un répertoire</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=27#a147</link>
                       <description>$ find . -name "*.txt" -print | xargs zip -qr archive.zip

</description>
                       <content:encoded><![CDATA[<pre><code>$ find . -name "*.txt" -print | xargs zip -qr archive.zip
</code></pre>
]]></content:encoded>
                       <category>shell</category>
                       </item><item>
                       <title>Ignore XCode personnal project files</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=49#a251</link>
                       <description>$ svn propset svn:ignore '*.pbxuser' '*.perspectivev3' MyProject.xcodeproj
$ svn commit -m "added propset to exclude personnal project files"

</description>
                       <content:encoded><![CDATA[<pre><code>$ svn propset svn:ignore '*.pbxuser' '*.perspectivev3' MyProject.xcodeproj
$ svn commit -m "added propset to exclude personnal project files"
</code></pre>
]]></content:encoded>
                       <category>svn</category>
                       </item><item>
                       <title>Mettre en place un repository local</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=49#a221</link>
                       <description>Sur http://www.codingmonkeys.de/mbo/, télécharger puis installer le dernier package Subversion-x.x.x.pkg pour Mac OS X.

créer le repository

$ svnadmin create /Users/nst/Library/SVNRep --fs-type fsfs


créer l'arborescence initiale

$ mkdir /tmp/svn_layout
$ mkdir /tmp/svn_layout/branches
$ mkdir /tmp/svn_layout/tags    
$ mkdir /tmp/svn_layout/trunk


importer l'arborescence initiale

$ svn import /tmp/svn_layout file:///Users/nst/Library/SVNRep -m "initial import"


importer un projet

$ svn import LifeLine file:///Users/nst/Library/SVNRep/trunk/LifeLine -m "LifeLine initial import"


lister les projets

$ svn list file:///Users/nst/Library/SVNRep/trunk/


récupérer un projet

$ svn checkout file:///Users/nst/Library/SVNRep/trunk/LifeLine LifeLine


afficher les logs

$ pwd
/Users/nst/Documents/Projects/LifeLine
$ svn log
------------------------------------------------------------------------
r2 | nst | 2007-06-03 16:06:47 +0200 (Dim, 03 jui 2007) | 1 line

LifeLine initial import
------------------------------------------------------------------------


pour le reste

Voir le svnbook.
</description>
                       <content:encoded><![CDATA[<p>Sur <a href="http://www.codingmonkeys.de/mbo/">http://www.codingmonkeys.de/mbo/</a>, télécharger puis installer le dernier package Subversion-x.x.x.pkg pour Mac OS X.</p>

<h4>créer le repository</h4>

<pre><code>$ svnadmin create /Users/nst/Library/SVNRep --fs-type fsfs
</code></pre>

<h4>créer l'arborescence initiale</h4>

<pre><code>$ mkdir /tmp/svn_layout
$ mkdir /tmp/svn_layout/branches
$ mkdir /tmp/svn_layout/tags    
$ mkdir /tmp/svn_layout/trunk
</code></pre>

<h4>importer l'arborescence initiale</h4>

<pre><code>$ svn import /tmp/svn_layout file:///Users/nst/Library/SVNRep -m "initial import"
</code></pre>

<h4>importer un projet</h4>

<pre><code>$ svn import LifeLine file:///Users/nst/Library/SVNRep/trunk/LifeLine -m "LifeLine initial import"
</code></pre>

<h4>lister les projets</h4>

<pre><code>$ svn list file:///Users/nst/Library/SVNRep/trunk/
</code></pre>

<h4>récupérer un projet</h4>

<pre><code>$ svn checkout file:///Users/nst/Library/SVNRep/trunk/LifeLine LifeLine
</code></pre>

<h4>afficher les logs</h4>

<pre><code>$ pwd
/Users/nst/Documents/Projects/LifeLine
$ svn log
------------------------------------------------------------------------
r2 | nst | 2007-06-03 16:06:47 +0200 (Dim, 03 jui 2007) | 1 line

LifeLine initial import
------------------------------------------------------------------------
</code></pre>

<h4>pour le reste</h4>

<p>Voir le <a href="http://svnbook.red-bean.com/">svnbook</a>.</p>
]]></content:encoded>
                       <category>svn</category>
                       </item><item>
                       <title>svn logs for the last 3 days</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=49#a287</link>
                       <description>$ svn log -v -r {`date -v-3d "+%Y-%m-%d"`}:HEAD


https://twitter.com/zacwhite/statuses/1965487642
</description>
                       <content:encoded><![CDATA[<pre><code>$ svn log -v -r {`date -v-3d "+%Y-%m-%d"`}:HEAD
</code></pre>

<p><a href="https://twitter.com/zacwhite/statuses/1965487642">https://twitter.com/zacwhite/statuses/1965487642</a></p>
]]></content:encoded>
                       <category>svn</category>
                       </item><item>
                       <title>tags</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=49#a215</link>
                       <description>Taguer la version courrante :

$ svn copy https://swisssms.googlecode.com/svn/trunk \
           https://swisssms.googlecode.com/svn/tags/release-1.2 \
           -m "tag on release 1.2"

$ svn copy file:///Users/nst/Library/SVNRep/trunk/phpMyFlatSite \
           file:///Users/nst/Library/SVNRep/tags/mfs_0_1 \
           -m "tag on mfs 0.1"


Taguer une ancienne version :

$ svn copy -r 13 \
    https://swisssms.googlecode.com/svn/trunk \
    https://swisssms.googlecode.com/svn/tags/release-1.1 \
    -m "forgotten tag on release 1.1"

</description>
                       <content:encoded><![CDATA[<p>Taguer la version courrante :</p>

<pre><code>$ svn copy https://swisssms.googlecode.com/svn/trunk \
           https://swisssms.googlecode.com/svn/tags/release-1.2 \
           -m "tag on release 1.2"

$ svn copy file:///Users/nst/Library/SVNRep/trunk/phpMyFlatSite \
           file:///Users/nst/Library/SVNRep/tags/mfs_0_1 \
           -m "tag on mfs 0.1"
</code></pre>

<p>Taguer une ancienne version :</p>

<pre><code>$ svn copy -r 13 \
    https://swisssms.googlecode.com/svn/trunk \
    https://swisssms.googlecode.com/svn/tags/release-1.1 \
    -m "forgotten tag on release 1.1"
</code></pre>
]]></content:encoded>
                       <category>svn</category>
                       </item><item>
                       <title>Deux tableaux côte-à-côte</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=10#a40</link>
                       <description>

\begin{table}[h!]
\begin{minipage}[t]{.4\linewidth}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multicolumn{5}{|l|}{queue de priorité} \\
    \hline
    E &amp; D &amp; C &amp;   &amp;   \\
    1 &amp; 2 &amp; 4 &amp;   &amp;   \\
    \hline
    \end{tabular}
\end{minipage}
\hfill
\begin{minipage}[t]{.4\linewidth}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multicolumn{5}{|l|}{tableau des pères} \\
    \hline
    A &amp; B &amp; C &amp; D &amp; E \\
    - &amp; A &amp; A &amp; B &amp; A \\
    \hline
    \end{tabular}
\end{minipage}
\end{table}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/tableaux/deux_tableaux_cote_a_cote.png" alt="Deux tableaux côte-à-côte" title="Deux tableaux côte-à-côte" /></p>

<pre><code>\begin{table}[h!]
\begin{minipage}[t]{.4\linewidth}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multicolumn{5}{|l|}{queue de priorité} \\
    \hline
    E &amp; D &amp; C &amp;   &amp;   \\
    1 &amp; 2 &amp; 4 &amp;   &amp;   \\
    \hline
    \end{tabular}
\end{minipage}
\hfill
\begin{minipage}[t]{.4\linewidth}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multicolumn{5}{|l|}{tableau des pères} \\
    \hline
    A &amp; B &amp; C &amp; D &amp; E \\
    - &amp; A &amp; A &amp; B &amp; A \\
    \hline
    \end{tabular}
\end{minipage}
\end{table}
</code></pre>
]]></content:encoded>
                       <category>Tableaux</category>
                       </item><item>
                       <title>Liens</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=10#a43</link>
                       <description>latex.perseguers.ch Un excellent guide sur les tableaux en LaTeX, par Xavier Perseguers
</description>
                       <content:encoded><![CDATA[<p><a href="http://latex.perseguers.ch/tableaux/">latex.perseguers.ch</a> Un excellent guide sur les tableaux en LaTeX, par Xavier Perseguers</p>
]]></content:encoded>
                       <category>Tableaux</category>
                       </item><item>
                       <title>Tableau adaptatif</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=10#a39</link>
                       <description>

Un tableau qui se redimensionne pour tenir sur une page.

Avec le package tabularx.

% les 'X' indiquent les colonnes dont la largeur peut être modifiée
\begin{tabularx}{450pt}{|c|X|c|X|c|c|c|c|c|c|c|c|c|c|c|}
\hline
Tâche         &amp; $\alpha$   &amp; T1       &amp; T2         &amp; T9       &amp; T3 &amp; T4 &amp; T6 &amp; T7 &amp; T5  &amp; T8  &amp; T10 &amp; T11 &amp; T12      &amp; $\omega$   \\
\hline
Numéro $k$    &amp; 1          &amp; 2        &amp; 3          &amp; 4        &amp; 5  &amp; 6  &amp; 7  &amp; 8  &amp; 9   &amp; 10  &amp; 11  &amp; 12  &amp; 13       &amp; 14         \\
\hline
Durée $d_{k}$ &amp; 0          &amp; 3        &amp; 2          &amp; 14       &amp; 4  &amp; 1  &amp; 3  &amp; 2  &amp; 6   &amp; 2   &amp; 6   &amp; 4   &amp; 3        &amp; 0          \\
\hline
\hline
$Pred(k)$     &amp; --         &amp; $\alpha$ &amp; $\alpha$   &amp; $\alpha$ &amp; T1 &amp; T2 &amp; T4 &amp; T2 &amp; T2  &amp; T7  &amp; T5  &amp; T9  &amp; T10      &amp; T12        \\
\hline
$t_{k}$       &amp; 0          &amp; 0        &amp; 0          &amp; 0        &amp; 3  &amp; 7  &amp; 8  &amp; 2  &amp; 2   &amp; 11  &amp; 13  &amp; 14  &amp; 19       &amp; 22         \\
\hline
\hline
$Succ(k)$     &amp; T1 T2 T9   &amp; T3       &amp; T4  T5  T7 &amp; T11      &amp; T4 &amp; T6 &amp; T8 &amp; T8 &amp; T10 &amp; T10 &amp; T12 &amp; T12 &amp; $\omega$ &amp; --         \\
\hline
$T_{k}$       &amp; 0          &amp; 0        &amp; 5          &amp; 1        &amp; 3  &amp; 7  &amp; 8  &amp; 9  &amp; 7   &amp; 11  &amp; 13  &amp; 15  &amp; 19       &amp; 22         \\
\hline
\end{tabularx}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/tableaux/tableau_adaptatif.png" alt="Tableau adaptatif" title="Tableau adaptatif" /></p>

<p>Un tableau qui se redimensionne pour tenir sur une page.</p>

<p>Avec le package tabularx.</p>

<pre><code>% les 'X' indiquent les colonnes dont la largeur peut être modifiée
\begin{tabularx}{450pt}{|c|X|c|X|c|c|c|c|c|c|c|c|c|c|c|}
\hline
Tâche         &amp; $\alpha$   &amp; T1       &amp; T2         &amp; T9       &amp; T3 &amp; T4 &amp; T6 &amp; T7 &amp; T5  &amp; T8  &amp; T10 &amp; T11 &amp; T12      &amp; $\omega$   \\
\hline
Numéro $k$    &amp; 1          &amp; 2        &amp; 3          &amp; 4        &amp; 5  &amp; 6  &amp; 7  &amp; 8  &amp; 9   &amp; 10  &amp; 11  &amp; 12  &amp; 13       &amp; 14         \\
\hline
Durée $d_{k}$ &amp; 0          &amp; 3        &amp; 2          &amp; 14       &amp; 4  &amp; 1  &amp; 3  &amp; 2  &amp; 6   &amp; 2   &amp; 6   &amp; 4   &amp; 3        &amp; 0          \\
\hline
\hline
$Pred(k)$     &amp; --         &amp; $\alpha$ &amp; $\alpha$   &amp; $\alpha$ &amp; T1 &amp; T2 &amp; T4 &amp; T2 &amp; T2  &amp; T7  &amp; T5  &amp; T9  &amp; T10      &amp; T12        \\
\hline
$t_{k}$       &amp; 0          &amp; 0        &amp; 0          &amp; 0        &amp; 3  &amp; 7  &amp; 8  &amp; 2  &amp; 2   &amp; 11  &amp; 13  &amp; 14  &amp; 19       &amp; 22         \\
\hline
\hline
$Succ(k)$     &amp; T1 T2 T9   &amp; T3       &amp; T4  T5  T7 &amp; T11      &amp; T4 &amp; T6 &amp; T8 &amp; T8 &amp; T10 &amp; T10 &amp; T12 &amp; T12 &amp; $\omega$ &amp; --         \\
\hline
$T_{k}$       &amp; 0          &amp; 0        &amp; 5          &amp; 1        &amp; 3  &amp; 7  &amp; 8  &amp; 9  &amp; 7   &amp; 11  &amp; 13  &amp; 15  &amp; 19       &amp; 22         \\
\hline
\end{tabularx}
</code></pre>
]]></content:encoded>
                       <category>Tableaux</category>
                       </item><item>
                       <title>Tableau avec formattage des colonnes</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=10#a38</link>
                       <description>

Avec le paquetage array.

\newcolumntype{t}{&gt;{\ttfamily}l}
\newcolumntype{m}{&gt;{\scshape}c}
\newcolumntype{g}{&gt;{\Large}r}


...

\begin{document}


...

\begin{tabular}{|t|m|g|}
Texte  &amp; Texte  &amp; Texte\\
Gauche &amp; Centré &amp; Droite
\end{tabular}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/tableaux/tableau_formattage_colonnes.png" alt="Tableau avec formattage des colonnes" title="Tableau avec formattage des colonnes" /></p>

<p>Avec le paquetage array.</p>

<pre><code>\newcolumntype{t}{&gt;{\ttfamily}l}
\newcolumntype{m}{&gt;{\scshape}c}
\newcolumntype{g}{&gt;{\Large}r}
</code></pre>

<p>...</p>

<pre><code>\begin{document}
</code></pre>

<p>...</p>

<pre><code>\begin{tabular}{|t|m|g|}
Texte  &amp; Texte  &amp; Texte\\
Gauche &amp; Centré &amp; Droite
\end{tabular}
</code></pre>
]]></content:encoded>
                       <category>Tableaux</category>
                       </item><item>
                       <title>Tableau complexe</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=10#a42</link>
                       <description>

\begin{table}[h!]
\begin{minipage}[t]{.4\linewidth}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multicolumn{5}{|l|}{queue de priorité} \\
    \hline
    E &amp; D &amp; C &amp;   &amp;   \\
    1 &amp; 2 &amp; 4 &amp;   &amp;   \\
    \hline
    \end{tabular}
\end{minipage}
\hfill
\begin{minipage}[t]{.4\linewidth}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multicolumn{5}{|l|}{tableau des pères} \\
    \hline
    A &amp; B &amp; C &amp; D &amp; E \\
    - &amp; A &amp; A &amp; B &amp; A \\
    \hline
    \end{tabular}
\end{minipage}
\end{table}

</description>
                       <content:encoded><![CDATA[<p><img src="http://quickies.seriot.ch/images/latex/tableaux/tableau_complexe_1.png" alt="Tableau complexe" title="Tableau complexe" /></p>

<pre><code>\begin{table}[h!]
\begin{minipage}[t]{.4\linewidth}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multicolumn{5}{|l|}{queue de priorité} \\
    \hline
    E &amp; D &amp; C &amp;   &amp;   \\
    1 &amp; 2 &amp; 4 &amp;   &amp;   \\
    \hline
    \end{tabular}
\end{minipage}
\hfill
\begin{minipage}[t]{.4\linewidth}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multicolumn{5}{|l|}{tableau des pères} \\
    \hline
    A &amp; B &amp; C &amp; D &amp; E \\
    - &amp; A &amp; A &amp; B &amp; A \\
    \hline
    \end{tabular}
\end{minipage}
\end{table}
</code></pre>
]]></content:encoded>
                       <category>Tableaux</category>
                       </item><item>
                       <title>diff en couleur</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=45#a182</link>
                       <description>$ svn diff | mate

</description>
                       <content:encoded><![CDATA[<pre><code>$ svn diff | mate
</code></pre>
]]></content:encoded>
                       <category>TextMate</category>
                       </item><item>
                       <title>Finder QuickLook plugin for .zip files</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=51#a240</link>
                       <description>http://homepage.mac.com/xdd/software/zip/
</description>
                       <content:encoded><![CDATA[<p><a href="http://homepage.mac.com/xdd/software/zip/">http://homepage.mac.com/xdd/software/zip/</a></p>
]]></content:encoded>
                       <category>Third Party apps</category>
                       </item><item>
                       <title>Install Internet Explorer for Windows on Mac OS X with Wine</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=51#a239</link>
                       <description>http://www.kronenberg.org/ies4osx/
</description>
                       <content:encoded><![CDATA[<p><a href="http://www.kronenberg.org/ies4osx/">http://www.kronenberg.org/ies4osx/</a></p>
]]></content:encoded>
                       <category>Third Party apps</category>
                       </item><item>
                       <title>Afficher les logs de démarrage</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=18#a213</link>
                       <description># dmesg

</description>
                       <content:encoded><![CDATA[<pre><code># dmesg
</code></pre>
]]></content:encoded>
                       <category>Utilitaires</category>
                       </item><item>
                       <title>Chiffrer et déchiffrer un fichier</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=18#a203</link>
                       <description>chiffrer

$ gpg -c file.txt


déchiffrer

$ gpg file.txt.gpg

</description>
                       <content:encoded><![CDATA[<p>chiffrer</p>

<pre><code>$ gpg -c file.txt
</code></pre>

<p>déchiffrer</p>

<pre><code>$ gpg file.txt.gpg
</code></pre>
]]></content:encoded>
                       <category>Utilitaires</category>
                       </item><item>
                       <title>Auto versioning with current date and svn revision</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=42#a228</link>
                       <description>Auto versioning with current date and svn revision

Here is an XCode run script build phase, setting your Cocoa app version to the latest date and svn revision each time you build. The values then appear in the Finder or in the application "About" panel.

In the XCode Project view, click on your target. Choose Project menu > New Build Phase > New Run Script Build Phase. Put this script just before "Copy Bundle Resources". Set the CFBundleVersion value to __myBundleVersion__.



Double-clic or apple-I on the Run Script build phase. Paste this python script. Don't forget to set the python path. Also check your svnversion, which may vary.



Clean your projet, build and run it. You should be able to see something like this.


</description>
                       <content:encoded><![CDATA[<p>Auto versioning with current date and svn revision</p>

<p>Here is an XCode run script build phase, setting your Cocoa app version to the latest date and svn revision each time you build. The values then appear in the Finder or in the application "About" panel.</p>

<p>In the XCode Project view, click on your target. Choose Project menu > New Build Phase > New Run Script Build Phase. Put <a href="/download/xcode_auto_version.py.txt">this script</a> just before "Copy Bundle Resources". Set the <code>CFBundleVersion</code> value to <code>__myBundleVersion__</code>.</p>

<p><a href="/images/xcode&#95;auto&#95;version/build&#95;phase.png"><img src="/images/xcode&#95;auto&#95;version/build&#95;phase.png" width="300" heigh="200" /></a></p>

<p>Double-clic or apple-I on the Run Script build phase. Paste this python script. Don't forget to set the python path. Also check your svnversion, which may vary.</p>

<p><a href="/images/xcode&#95;auto&#95;version/python&#95;script.png"><img src="/images/xcode&#95;auto&#95;version/python&#95;script.png" width="300" heigh="200" /></a></p>

<p>Clean your projet, build and run it. You should be able to see something like this.</p>

<p><a href="/images/xcode&#95;auto&#95;version/about.png"><img src="/images/xcode&#95;auto&#95;version/about.png" width="300" heigh="200" /></a></p>
]]></content:encoded>
                       <category>Xcode</category>
                       </item><item>
                       <title>Generate GraphViz dot file of compilation dependancies</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=42#a285</link>
                       <description>defaults write com.apple.Xcode GenerateGraphVizFiles -bool YES


Thank you 0xced.
</description>
                       <content:encoded><![CDATA[<pre><code>defaults write com.apple.Xcode GenerateGraphVizFiles -bool YES
</code></pre>

<p>Thank you 0xced.</p>
]]></content:encoded>
                       <category>Xcode</category>
                       </item><item>
                       <title>Jump around in interCapitializedWords</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=42#a257</link>
                       <description>Control + arrow keys.
</description>
                       <content:encoded><![CDATA[<p>Control + arrow keys.</p>
]]></content:encoded>
                       <category>Xcode</category>
                       </item><item>
                       <title>Keep more than 10 projects in File menu</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=42#a269</link>
                       <description>$ defaults write com.apple.Xcode NSRecentDocumentsLimit 25

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults write com.apple.Xcode NSRecentDocumentsLimit 25
</code></pre>
]]></content:encoded>
                       <category>Xcode</category>
                       </item><item>
                       <title>mettre un breakpoint sur une exception</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=42#a200</link>
                       <description>
aller dans menu Debug > Breakpoints
ajouter le nom de l'exception objc_exception_throw


Voir developer.apple.com
</description>
                       <content:encoded><![CDATA[<ol>
<li>aller dans menu Debug > Breakpoints</li>
<li>ajouter le nom de l'exception <code>objc_exception_throw</code></li>
</ol>

<p>Voir <a href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/XcodeUserGuide20/Contents/Resources/en.lproj/db_controlling_execution/chapter_40_section_2.html">developer.apple.com</a></p>
]]></content:encoded>
                       <category>Xcode</category>
                       </item><item>
                       <title>pragma mark dans XCode</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=42#a136</link>
                       <description>#pragma mark -
#pragma mark NSTableDataSource protocol



</description>
                       <content:encoded><![CDATA[<pre><code>#pragma mark -
#pragma mark NSTableDataSource protocol
</code></pre>

<p><img src="http://quickies.seriot.ch/images/cocoa/pragma_mark.png" alt="pragma mark" /></p>
]]></content:encoded>
                       <category>Xcode</category>
                       </item><item>
                       <title>Stop prompting to save files in other editors</title>
                       <link>http://quickies.seriot.ch/index.php?p=default&amp;cat=42#a290</link>
                       <description>$ defaults delete com.apple.Xcode PBXExternalEditorList

</description>
                       <content:encoded><![CDATA[<pre><code>$ defaults delete com.apple.Xcode PBXExternalEditorList
</code></pre>
]]></content:encoded>
                       <category>Xcode</category>
                       </item>   </channel>
</rss>