<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users123</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/123" rel="self"/>
  <title>griflet</title>
  <updated>Sat May 31 00:52:35 -0700 2008</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code305</id>
    <published>2008-05-31T00:52:35-07:00</published>
    <updated>2008-05-31T09:36:01-07:00</updated>
    <title>[JavaScript] Tarpipe to twitter, jaiku and pownce</title>
    <content type="html">&lt;p&gt;&amp;lt;a href=&amp;quot;&lt;a href="http://tarpipe.com" target="_blank"&gt;http://tarpipe.com&lt;/a&gt;&amp;quot; &amp;gt;Tarpipe&amp;lt;/a&amp;gt; is a service similar to yahoo pipes. It allows to send REST-wise posts to twitter, jaiku and pownce in one shot ;) Here's a short bookmarklet that should help you get productive on those micro-blogging platforms. Please teach me how to write better javascript. Thanks.&lt;/p&gt;

&lt;pre&gt;javascript:
popw=window.open('','Tarpipe micro-post','width=800,height=150');
popw.focus();
popd=popw.document;

popd.write('&amp;lt;form action=&amp;quot;http://rest.receptor.tarpipe.net:8000/?key=PUTYOURKEYHERE&amp;quot; method=&amp;quot;POST&amp;quot; enctype=&amp;quot;multipart/form-data&amp;quot;&amp;gt;');
popd.write('&amp;lt;p&amp;gt;&amp;lt;input type=&amp;quot;text&amp;quot; size=&amp;quot;90&amp;quot; name=&amp;quot;title&amp;quot; value=%s '+location.href/&amp;gt;&amp;lt;/p&amp;gt;');
popd.write('&amp;lt;p&amp;gt;&amp;lt;input type=&amp;quot;submit&amp;quot; name=&amp;quot;Submit&amp;quot; value=&amp;quot;pipe&amp;quot;/&amp;gt;&amp;lt;/p&amp;gt;');
popd.write('&amp;lt;/form&amp;gt;');
&lt;/pre&gt;</content>
    <author>
      <name>griflet</name>
      <email>guillaume.riflet@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/305-tarpipe-to-twitter-jaiku-and-pownce" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code244</id>
    <published>2008-02-27T23:49:55-08:00</published>
    <updated>2008-04-08T16:49:45-07:00</updated>
    <title>[JavaScript] Zoom all image files from small to medium, medium to large etc..</title>
    <content type="html">&lt;p&gt;This one comes straight from Phillipe Lenssen's blog (&lt;a href="http://blogoscoped.com/archive/2008-02-26-n57.html" target="_blank"&gt;http://blogoscoped.com/archive/2008-02-26-n57.html&lt;/a&gt;) where he shares with us this javascript bookmarklet hack to be used within friendfeed or any other web-page that uses &amp;quot;small&amp;quot; &amp;quot;medium&amp;quot; &amp;quot;large&amp;quot; parameter to encode their images...
&lt;br /&gt;You may need to tweak with the width and height; and with the &amp;quot;medium&amp;quot; to &amp;quot;large&amp;quot; parameters...&lt;/p&gt;

&lt;pre&gt;javascript:(function(){
    var elm = document.getElementsByTagName(&amp;quot;img&amp;quot;);
    for (var i = 0; i &amp;lt; elm.length; i++) {
        var sOld = elm[i].getAttribute(&amp;quot;src&amp;quot;);
        var sNew = sOld.replace(/=medium/g, &amp;quot;=large&amp;quot;);
        if (sOld != sNew) {
            elm[i].setAttribute(&amp;quot;src&amp;quot;, sNew);
            elm[i].setAttribute(&amp;quot;style&amp;quot;,
                    &amp;quot;width:75px; height:75px&amp;quot;);
        }
    }
})()&lt;/pre&gt;</content>
    <author>
      <name>griflet</name>
      <email>guillaume.riflet@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/244-zoom-all-image-files-from-small-to-medium-medium-to-large-etc" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor2369</id>
    <published>2008-02-17T03:13:27-08:00</published>
    <title>[JavaScript] On Mathtex bookmarklet</title>
    <content type="html">&lt;p&gt;Ok, I've made this one a little bit more handy. I've added text areas with image url and embeddable html code for your webpage, wiki or blog. &lt;/p&gt;

&lt;pre&gt;javascript:

popw='';
str=prompt(&amp;quot;Type your tex:&amp;quot;,&amp;quot;%s&amp;quot;);

cols=50;
match=/&amp;lt;([^&amp;lt;&amp;gt;]*)&amp;gt;/g;
subs=&amp;quot;&amp;amp;lt;$1&amp;amp;gt;&amp;quot;;

if(str){

    popw=window.open(
        '',
        'latexbox',
        'width=440,height=250'
    );
    popw.focus();


    imglnk='http://www.forkosh.dreamhost.com/mathtex.cgi?'+escape(str);
    textimglnk='&amp;lt;textarea rows=&amp;quot;1&amp;quot; cols=&amp;quot;'+cols+'&amp;quot;&amp;gt;'+imglnk.replace(match,subs)+'&amp;lt;/textarea&amp;gt;';

    imgtag='&amp;lt;img src=&amp;quot;'+imglnk+'&amp;quot; alt=&amp;quot;'+str+'&amp;quot;&amp;gt;&amp;lt;/img&amp;gt;';

    divtag='&amp;lt;div style=&amp;quot;text-align:center;width:100%&amp;quot; &amp;gt;'+imgtag+'&amp;lt;/div&amp;gt;';
    textdivtag='&amp;lt;textarea rows=&amp;quot;3&amp;quot; cols=&amp;quot;'+cols+'&amp;quot;&amp;gt;'+divtag.replace(match,subs)+'&amp;lt;/textarea&amp;gt;';

    popd=popw.document;
    popd.write(imgtag+'&amp;lt;/br&amp;gt;');
    popd.write('link: '+textimglnk+'&amp;lt;/br&amp;gt;');
    popd.write('html: '+textdivtag+'&amp;lt;/br&amp;gt;');

}&lt;/pre&gt;</content>
    <author>
      <name>griflet</name>
      <email>guillaume.riflet@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/234-mathtex-bookmaklet/refactors/2369" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code234</id>
    <published>2008-02-15T11:11:38-08:00</published>
    <updated>2008-02-21T17:58:23-08:00</updated>
    <title>[JavaScript] Mathtex bookmarklet</title>
    <content type="html">&lt;p&gt;Join the lines and save it as a bookmark.&lt;/p&gt;

&lt;p&gt;This one aims to help users to embed latex equations in their blogs and wikis by using Mathtex and a little javascript bookmarklet.&lt;/p&gt;

&lt;p&gt;&amp;lt;a href=&amp;quot;javascript:popw='';y=window;str=prompt(%22Type%20your%20tex:%22,%22%s%22);if(str)%7Bpopw=window.open('http://www.forkosh.dreamhost.com/mathtex.cgi?'+escape(str),'latexbox','width=300,height=200');popw.focus();if (!document.all) T = setTimeout('popw.focus()',50)%7Dvoid(0);&amp;quot; &amp;gt;mathtex box&amp;lt;/a&amp;gt;&lt;/p&gt;

&lt;pre&gt;javascript:
popw='';
y=window;
str=prompt(&amp;quot;Type your tex:&amp;quot;,&amp;quot;%s&amp;quot;);
if(str){
    popw=window.open(
        'http://www.forkosh.dreamhost.com/mathtex.cgi?'+escape(str),
        'latexbox',
        'width=300,height=200'
    );
    popw.focus();
    if (!document.all) T = setTimeout('popw.focus()',50)
}
void(0);&lt;/pre&gt;</content>
    <author>
      <name>griflet</name>
      <email>guillaume.riflet@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/234-mathtex-bookmaklet" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor1882</id>
    <published>2008-01-29T18:47:24-08:00</published>
    <title>[PHP] On MediaWiki extension template</title>
    <content type="html">&lt;p&gt;Hmmm, nice! 
&lt;br /&gt;And about this variant that does the &amp;quot;feeling lucky&amp;quot; magic link? It creates a &amp;lt;goto&amp;gt; tag. Pretty neat, huh? ;)
&lt;br /&gt;Sure saves me a-lot-of-time when posting articles in mediawiki or in wordpress...&lt;/p&gt;

&lt;p&gt;BTW, remember to append 'include(&amp;quot;extensions/goto.php&amp;quot;);' to the LocalSettings.php file in your mediawiki directory.&lt;/p&gt;

&lt;pre&gt;&amp;lt;?php
# goto
# 
# Tag :
#   &amp;lt;goto&amp;gt;search string&amp;lt;/goto&amp;gt;
# 
# Enjoy !

$wgExtensionFunctions[] = 'wfgoto';
$wgExtensionCredits['parserhook'][] = array(
        'name' =&amp;gt; 'goto',
        'description' =&amp;gt; 'Google &amp;quot;Feeling Lucky&amp;quot; linking',
        'author' =&amp;gt; 'Guillaume Riflet',
        'url' =&amp;gt; 'http://meta.wikimedia.org/wiki/goto'
);

function wfgoto() {
        global $wgParser;
        $wgParser-&amp;gt;setHook('goto', 'rendergoto');
}

# The callback function for converting the input text to HTML output
function rendergoto($input) {      
        $output='&amp;lt;a href=&amp;quot;http://www.google.com/search?hl=en&amp;amp;q='.$input.'&amp;amp;btnI=kudos&amp;quot; &amp;gt;'.$input.'&amp;lt;/a&amp;gt;';
        return $output;
}
?&amp;gt;&lt;/pre&gt;</content>
    <author>
      <name>griflet</name>
      <email>guillaume.riflet@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/222-mediawiki-extension-template/refactors/1882" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code222</id>
    <published>2008-01-29T18:42:20-08:00</published>
    <updated>2008-02-18T22:10:00-08:00</updated>
    <title>[PHP] MediaWiki extension template</title>
    <content type="html">&lt;p&gt;Here's a nice little template for MediaWiki that allows to embed generic html using the &amp;lt;htm&amp;gt; tag :)&lt;/p&gt;

&lt;pre&gt;&amp;lt;?php
# html
# 
# Tag :
#   &amp;lt;htm&amp;gt;html code&amp;lt;/htm&amp;gt;
# 
# Enjoy !

$wgExtensionFunctions[] = 'wfhtml';
$wgExtensionCredits['parserhook'][] = array(
        'name' =&amp;gt; 'html',
        'description' =&amp;gt; 'Display html',
        'author' =&amp;gt; 'Guillaume Riflet',
        'url' =&amp;gt; 'http://meta.wikimedia.org/wiki/html'
);

function wfhtml() {
        global $wgParser;
        $wgParser-&amp;gt;setHook('htm', 'renderhtml');
}

# The callback function for converting the input text to HTML output
function renderhtml($input) {      
        $output=$input;
        return $output;
}
?&amp;gt;&lt;/pre&gt;</content>
    <author>
      <name>griflet</name>
      <email>guillaume.riflet@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/222-mediawiki-extension-template" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor899</id>
    <published>2007-11-20T18:00:34-08:00</published>
    <title>[Perl] On Perl one-liner to extract xml tags values</title>
    <content type="html">&lt;p&gt;Tested. Works. I also added a sed command to remove blank lines. Anyone cares to insert that in the perl one-liner, for sports?&lt;/p&gt;

&lt;pre&gt;curl http://www.cnn.com | perl -ne 'm/&amp;gt;([^&amp;lt;&amp;gt;]*?)&amp;lt;\// &amp;amp;&amp;amp; print$1.&amp;quot;\n&amp;quot;' | sed -e '/^$/d'&lt;/pre&gt;</content>
    <author>
      <name>griflet</name>
      <email>guillaume.riflet@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/151-perl-one-liner-to-extract-xml-tags-values/refactors/899" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code151</id>
    <published>2007-11-13T17:19:53-08:00</published>
    <updated>2009-12-29T17:58:39-08:00</updated>
    <title>[Perl] Perl one-liner to extract xml tags values</title>
    <content type="html">&lt;p&gt;Hello,
&lt;br /&gt;I'm a web-scrapping enthusiast and I script short one-liners in bash using sed, awk, perl, grep, tail, head, tr,... that sort of programs. Here's a really cool perl one-liner that basically extracts values from any xml(html) tag. You should try it. Can you make it shorter, or any more powerful?
&lt;br /&gt;Cheers,
&lt;br /&gt;Guillaume&lt;/p&gt;

&lt;pre&gt;curl http://www.cnn.com | perl -ne 'm/&amp;gt;([^&amp;lt;].*?[^&amp;gt;])&amp;lt;\// &amp;amp;&amp;amp; print$1.&amp;quot;\n&amp;quot;'&lt;/pre&gt;</content>
    <author>
      <name>griflet</name>
      <email>guillaume.riflet@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/151-perl-one-liner-to-extract-xml-tags-values" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code51</id>
    <published>2007-10-03T02:15:05-07:00</published>
    <updated>2011-09-03T17:03:42-07:00</updated>
    <title>[Python] Classtemplate</title>
    <content type="html">&lt;p&gt;I'm new to python (and to OO programming in general). But I really enjoyed discovering the pydoc and the unittesting, doctest, concepts. Here's a first draft of a python primer ... Can you improve it?&lt;/p&gt;

&lt;pre&gt;#! /usr/bin/python
&amp;quot;&amp;quot;&amp;quot; A python primer. pydoc, doctest and classes.

Syntax:
 To generate man pages:
 &amp;gt; pydoc classtemplate

 To try all the tests in doctest (and execute the script):
 &amp;gt; python classtemplate.py -v
&amp;quot;&amp;quot;&amp;quot;

#Class definition
class Table:
        &amp;quot;&amp;quot;&amp;quot;Class Table.

        Doctest: here we insert python command lines inputs and outputs.
        &amp;gt;&amp;gt;&amp;gt; print Table.database
        http://access.com/db
        &amp;quot;&amp;quot;&amp;quot;

        #Data attributes here
        database='http://access.com/db'

        #Method attributes here
        def __init__(self,id,text):
                &amp;quot;&amp;quot;&amp;quot;Initializes the id and textlabel data attributes.

                Doctest: Testing more data attributes defined at construction time
                &amp;gt;&amp;gt;&amp;gt; x = Table(1,'coucou')
                &amp;gt;&amp;gt;&amp;gt; print x.id
                1
                &amp;gt;&amp;gt;&amp;gt; print x.textlabel
               coucou
                &amp;quot;&amp;quot;&amp;quot;
                self.id=id
                self.textlabel=text

#doctest -- &amp;quot;Debugging sucks :( Testing rocks :)&amp;quot;
def _test():
        &amp;quot;&amp;quot;&amp;quot;Inline Doctest activated. Cool! :D
         This means that whenever the module is called in python
 
        &amp;gt; python thismodule.py -v
 
        the doctest function will try all the tests implemented in doctest.
        &amp;quot;&amp;quot;&amp;quot;
        import doctest
        doctest.testmod()

if __name__ == &amp;quot;__main__&amp;quot;:
        _test()&lt;/pre&gt;</content>
    <author>
      <name>griflet</name>
      <email>guillaume.riflet@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/51-classtemplate" rel="alternate"/>
  </entry>
</feed>

