<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Michele Campeotto: Tag script</title>
    <link>http://blog.micampe.it/articles/tag/script?tag=script</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>I'm not Winston Wolfe.</description>
    <item>
      <title>Enhanced buftabs Vim Plugin</title>
      <description>&lt;p&gt;After a couple of days using my &lt;a href="http://blog.micampe.it/articles/2007/03/25/tabs-in-vim-and-my-first-plugin"&gt;bufpos&lt;/a&gt; vim plugin together with &lt;a href="http://www.vim.org/scripts/script.php?script_id=1664"&gt;buftabs&lt;/a&gt;, I realized I didn&amp;#8217;t need the buffer numbers in the status line (I can always get them with &lt;code&gt;:ls&lt;/code&gt;), but their position number would have been very useful.&lt;/p&gt;

&lt;p&gt;So here is my &lt;a href="http://micampe.it/files/buftabs.vim"&gt;modified version&lt;/a&gt; with these three changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the tab numbers indicate the the number you have press to get there instead of the buffer number&lt;/li&gt;
&lt;li&gt;improved &lt;code&gt;autocmd&lt;/code&gt; settings to better synchronize the &lt;code&gt;!&lt;/code&gt; modified flag&lt;/li&gt;
&lt;li&gt;different &lt;a href="http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers"&gt;filename shortening mode&lt;/a&gt;, now it is displayed with a path relative to the current or home directory (don&amp;#8217;t set &lt;code&gt;g:buftabs_only_basename&lt;/code&gt; to get that)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have contacted the &lt;code&gt;buftabs&lt;/code&gt; author and the last two will be in the next &lt;code&gt;buftabs&lt;/code&gt; release too.&lt;/p&gt;</description>
      <pubDate>Wed, 28 Mar 2007 10:16:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:e444b8a0-7aee-45a9-a71d-7adbd26d0d0a</guid>
      <author>micampe</author>
      <link>http://blog.micampe.it/articles/2007/03/28/enhanced-buftabs-vim-plugin</link>
      <category>English</category>
      <category>vim</category>
      <category>script</category>
      <category>plugin</category>
      <trackback:ping>http://blog.micampe.it/articles/trackback/1084</trackback:ping>
    </item>
    <item>
      <title>Tabs in Vim and My First Plugin</title>
      <description>&lt;p&gt;One of the most talked about features of Vim7 are &lt;a href="http://www.linux.com/article.pl?sid=07/01/11/2141259"&gt;tabs&lt;/a&gt;, but I don&amp;#8217;t like them very much, I think they should have been given a different name. They could have been called &lt;em&gt;layouts&lt;/em&gt;, for example, because they are very different from what most people expect and much more similar to Eclipse&amp;#8217;s perspectives or NetBeans workspaces than to Firefox tabs.&lt;/p&gt;

&lt;p&gt;I find buffers, which have been in Vim since pretty much forever, are a very convenient way to edit multiple files. You just have to tune them a bit.&lt;/p&gt;

&lt;p&gt;First, you absolutely have to set the &lt;code&gt;hidden&lt;/code&gt; option, so you can switch between buffers without being forced to save them, and then you need some key mappings:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set hidden
map &amp;lt;C-TAB&amp;gt; :bnext!&amp;lt;CR&amp;gt;
map &amp;lt;C-S-TAB&amp;gt; :bprev!&amp;lt;CR&amp;gt;
map &amp;lt;C-\&amp;gt; :b#&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Use &lt;code&gt;Ctrl-Tab&lt;/code&gt; and &lt;code&gt;Ctrl-Shift-Tab&lt;/code&gt; to navigate through the list of open buffers and &lt;code&gt;Ctrl-\&lt;/code&gt; to quickly toggle between two open files.&lt;/p&gt;

&lt;p&gt;After using this setup for quite some time, about a week ago I found &lt;a href="http://www.vim.org/scripts/script.php?script_id=1664"&gt;buftabs&lt;/a&gt;, a simple plugin that displays the open buffers in the status line. I like simple plugins, my rule is that they have to be useful without me having to actually learn to use them or even remember they are there.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set laststatus=2
let g:buftabs_in_statusline=1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I then added two more mappings to navigate through buffers, to better match the visual representation &lt;code&gt;buftabs&lt;/code&gt; provides.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;map &amp;lt;C-b&amp;gt; :bprev!&amp;lt;CR&amp;gt;
map &amp;lt;C-n&amp;gt; :bnext!&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With these switching buffers is even easier, as you have a visual indication of which buffer you are going to activate.&lt;/p&gt;

&lt;p&gt;Just one last piece was missing from this picture: most tabs implementations allow you to directly activate a tab by pressing the &lt;code&gt;Alt&lt;/code&gt; key and a number, like Firefox, for example.&lt;/p&gt;

&lt;p&gt;So here comes my first Vim script ever: &lt;a href="http://www.vim.org/scripts/script.php?script_id=1836"&gt;bufpos&lt;/a&gt; is a very simple script that maps &lt;code&gt;Alt-number&lt;/code&gt; keys to activate buffers.&lt;/p&gt;

&lt;p&gt;Note that you don&amp;#8217;t have to use the buffer number &lt;code&gt;buftabs&lt;/code&gt; puts beside the file name, but the position in the buffers list.&lt;/p&gt;</description>
      <pubDate>Sun, 25 Mar 2007 14:05:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:162bb42d-555f-4014-a7cf-58c3c8e81ade</guid>
      <author>micampe</author>
      <link>http://blog.micampe.it/articles/2007/03/25/tabs-in-vim-and-my-first-plugin</link>
      <category>English</category>
      <category>vim</category>
      <category>script</category>
      <category>plugin</category>
      <trackback:ping>http://blog.micampe.it/articles/trackback/1083</trackback:ping>
    </item>
    <item>
      <title>Free your iPod shuffle</title>
      <description>&lt;p&gt;This made my day: I just found on &lt;a href="http://www.macosxhints.com/article.php?story=2005040610284411"&gt;macosxhints&lt;/a&gt; a Python script that can be used to &lt;a href="http://www-user.tu-chemnitz.de/~mfie/index.php?software=ipod" title="iPod shuffle Database Builder"&gt;build a songs database for the iPod shuffle&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The best thing about the script is that you can put the song files however you like on the iPod and the script will happily find them and build the files needed by the device to play them. This is amazing: not only it&amp;#8217;s much easier to use than GNUpod or similar tools, I can actually keep it directly in my iPod and use it everywhere, I just need Python to be installed.&lt;/p&gt;

&lt;p&gt;In a quick email exchange with Martin &amp;#8211; the script&amp;#8217;s author &amp;#8211; I also discovered that it sorts the songs according to the folders I place them in and alphabetically inside the folders.&lt;/p&gt;

&lt;p&gt;I guess I don&amp;#8217;t need much more. Thank you Martin.&lt;/p&gt;</description>
      <pubDate>Thu, 07 Apr 2005 09:59:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:96eaf16a-4bff-4cba-b885-ac5416742f73</guid>
      <author>micampe</author>
      <link>http://blog.micampe.it/articles/2005/04/07/free-your-ipod-shuffle</link>
      <category>English</category>
      <category>ipod</category>
      <category>shuffle</category>
      <category>script</category>
      <trackback:ping>http://blog.micampe.it/articles/trackback/173</trackback:ping>
    </item>
    <item>
      <title>FlickrUploadr</title>
      <description>&lt;div class="flickr-frame" style="float: right; text-align: center; margin-left: 15px; margin-bottom: 15px;"&gt;
  &lt;a href="http://www.flickr.com/photo.gne?id=458376" title="photo sharing"&gt;&lt;img src="http://www.flickr.com/photos/458376_cacbb76fae_o_d.png" class="flickr-photo" style="border: 0;" alt="FlickrUploadr"&gt;&lt;/a&gt;
&lt;/div&gt;

&lt;p&gt;FlickrUploadr is a tool to upload your pictures to &lt;a href="http://flickr.com"&gt;Flickr&lt;/a&gt;. There are some &lt;a href="http://flickr.com/tools/"&gt;official tools&lt;/a&gt; for this task, but they aren&amp;#8217;t available on Linux, so I wrote my own.&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;Please note that FlickrUploadr doesn&amp;#8217;t currently work if you have a Yahoo! account. I&amp;#8217;ll try to update it soon.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This version of FlickrUploadr is written in Python and Gtk, using the PyGtk bindings, to install it, download the tarball, unpack it and install the package:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# python setup.py install
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;in the directory where you just unpacked it. If you get an error about a missing Makefile, you need to install the Python development package from your distribution.&lt;/p&gt;

&lt;p&gt;Then you can run it from a shell:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ Uploadr
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Just drop files over the window to upload the pictures.&lt;/p&gt;

&lt;p&gt;A window will pop up asking your login details (which you can optinally save) and the picture&amp;#8217;s metadata (title and tags). At the end of the upload a web browser window (currently Firefox is hardcoded, sorry) will open with the pictures you just uploaded, allowing you to add descriptions and change the captions one by one.&lt;/p&gt;

&lt;h2&gt;History&lt;/h2&gt;

&lt;h3&gt;30 August 2005&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://micampe.it/files/FlickrUploadr-0.6.0.tar.gz"&gt;FlickrUploadr 0.6.0&lt;/a&gt; &amp;#8211; Finally the much requested configuration saving (optional for login credentials). Removed the hardcoded firefox. No longer sets default title. Changed license to GPL to comply with xmltramp.&lt;/p&gt;

&lt;h3&gt;18 March 2005&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://micampe.it/files/FlickrUploadr-0.5.2.tar.gz"&gt;FlickrUploadr 0.5.2&lt;/a&gt; &amp;#8211; Fixed to work with Python 2.4. If the previous version worked for you, you don&amp;#8217;t need to download it again.&lt;/p&gt;

&lt;h3&gt;21 October 2004&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://micampe.it/files/FlickrUploadr-0.5.1.tar.gz"&gt;FlickrUploadr 0.5.1&lt;/a&gt; &amp;#8211; Fixed to accept files dropped from Konqueror. Fixed long integer exception and crash. On some systems it will have a black  background instead of white and look uglier, but I don&amp;#8217;t know ho to fix this for everybody.&lt;/p&gt;

&lt;h3&gt;12 October 2004&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://micampe.it/files/FlickrUploadr-0.5.tar.gz"&gt;FlickrUploadr 0.5&lt;/a&gt; &amp;#8211; Installable and runnable from anywhere, login details asked when needed, can drop pictures or pass them on the command line, can set pictures as private, opens Flickr after uploading allowing editing of pictures&amp;#8217; data.&lt;/p&gt;

&lt;h3&gt;16 September 2004&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://micampe.it/files/FlickrUploadr-0.1.tar.gz"&gt;FlickrUploadr 0.1&lt;/a&gt; &amp;#8211;
&lt;a href="http://flickr.com/groups_topic.gne?id=4641"&gt;First release&lt;/a&gt;: uploading works, you have to pass the login details on the command line, can&amp;#8217;t be installed must be run from its own directory.&lt;/p&gt;</description>
      <pubDate>Sat, 19 Mar 2005 01:17:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:7c5c74dd-c328-4f73-8b14-f8558ed448ee</guid>
      <author>micampe</author>
      <link>http://blog.micampe.it/articles/2005/03/19/flickruploadr</link>
      <category>English</category>
      <category>flickr</category>
      <category>python</category>
      <category>script</category>
      <category>programming</category>
      <category>uploadr</category>
      <trackback:ping>http://blog.micampe.it/articles/trackback/119</trackback:ping>
    </item>
    <item>
      <title>FlickrClient</title>
      <description>&lt;p&gt;FlickrClient is a Python interface to the &lt;a href="http://flickr.com/services/api"&gt;Flickr API&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Using it really simple: create a FlickrClient instance passing your API_KEY to the constructor and then call the methods on the returned instance, replacing dots with underscores.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;client = FlickrClient(API_KEY)

person = client.flickr_people_getInfo(user_id=USER_ID)
photoSets = client.flickr_photosets_getList(user_id=USER_ID)

print person.username, "has", len(photoSets), "photosets:",
print ', '.join([str(set.title) for set in photoSets])
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I used &lt;a href="http://www.aaronsw.com/2002/xmltramp/"&gt;xmltramp&lt;/a&gt; to parse the responses and I return the created xmltramp object, so accessing the data is really simple: you access sub-elements just as if they were attributes of your node and attribute access is done as a function call on the node: &lt;code&gt;person('id')&lt;/code&gt;, to retrieve the text element of a node, convert it to string: &lt;code&gt;str(person.username)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The client dynamically creates the calls, so it shouldn&amp;#8217;t break when new functions are added to Flickr or if parameters change (you&amp;#8217;ll have to change your calls, of course).&lt;/p&gt;

&lt;p&gt;I also have developed a Python &lt;a href="uploadr.html"&gt;FlickrUploadr&lt;/a&gt; to upload your pictures from Linux (or anywhere else you can get Python and &lt;a href="http://pygtk.org"&gt;PyGtk&lt;/a&gt; to build).&lt;/p&gt;

&lt;h2&gt;Download&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://micampe.it/files/FlickrClient-0.2.tar.gz"&gt;FlickrClient 0.2&lt;/a&gt; &amp;mdash; Fixed bug on requests returning an empty response (Thanks to Tom Insam for catching this)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://micampe.it/files/FlickrClient-0.1.tar.gz"&gt;FlickrClient 0.1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Sat, 19 Mar 2005 01:17:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:9402e76f-7212-4aee-b74b-eb51d2e77fac</guid>
      <author>micampe</author>
      <link>http://blog.micampe.it/articles/2005/03/19/flickrclient</link>
      <category>English</category>
      <category>flickr</category>
      <category>python</category>
      <category>script</category>
      <category>programming</category>
      <trackback:ping>http://blog.micampe.it/articles/trackback/116</trackback:ping>
    </item>
    <item>
      <title>Nautilus Quick Burner</title>
      <description>&lt;p&gt;This script comes from an &lt;a href="http://mail.gnome.org/archives/nautilus-list/2002-March/msg00553.html"&gt;idea&lt;/a&gt; launched on the Nautilus mailing list by Tuomas Kuosmanen, who wished a workaround while waiting for somebody to implement drag and drop CD-RW burning in Nautilus.&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; That idea is now implemented and included in the official Nautilus release.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I don&amp;#8217;t think I can implement his whole idea, but I can quickly hack a simple Python/GTK+ script that does part of the job.&lt;/p&gt;

&lt;p&gt;The script is meant to be used as a Nautilus script, but it doesn&amp;#8217;t contain anything Nautilus related, so you can use it from the CLI too: just specify as command line arguments the files/directories you want to burn. You can also launch it as a standalone program and drop the files in the main window.&lt;/p&gt;

&lt;p&gt;The script is &lt;em&gt;simple and dirty&lt;/em&gt;, &lt;strong&gt;almost no error checking&lt;/strong&gt; is performed, and to configure it you must edit the source file.&lt;/p&gt;

&lt;p&gt;By default it will not burn anything, it will just create an &lt;code&gt;image.img&lt;/code&gt; file in the directory where you run it. If you want the script to actually burn your CDs, you should edit the file, change the command line (a commented out example is provided) and remove the &lt;code&gt;-dummy&lt;/code&gt; option (yeah, I know this sucks, but I don&amp;#8217;t want to burn your CD writer with some wrong option).&lt;/p&gt;

&lt;p&gt;Clicking the &lt;code&gt;Cancel&lt;/code&gt; button or closing the burning window will immediately stop the execution. You&amp;#8217;ll not be asked for confirmation, but you&amp;#8217;ve been warned now! ;o)&lt;/p&gt;

&lt;p&gt;You can see the results of the script by loopback-mounting the generated &lt;code&gt;image.img&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;
# mount -t iso9660 -o loop image.img /mnt/cdrom
&lt;/pre&gt;

&lt;h3&gt;Screenshots&lt;/h3&gt;

&lt;div align="center"&gt;
  &lt;img src="http://micampe.it/screens/quickburn-1-shadow.png" alt="Screenshot 1" /&gt;
  &lt;img src="http://micampe.it/screens/quickburn-2-shadow.png" alt="Screenshot 2" /&gt;
&lt;/div&gt;

&lt;h3&gt;Requirements&lt;/h3&gt;

&lt;p&gt;To run the Nautilus Quick Burner you&amp;#8217;ll need GTK+ 2.x (1.3.x may work, too), the latest version of PyGTK (anything over 1.99.7 should work) and a recent version mkisofs and cdrecord (tested with 1.10).&lt;/p&gt;

&lt;p&gt;Also note that the user running the script needs to have execution
permissions on mkisofs and cdrecord (this isn&amp;#8217;t true by default on Red Hat systems).&lt;/p&gt;

&lt;h3&gt;Download &amp;amp; install&lt;/h3&gt;

&lt;p&gt;Download &lt;a href="http://micampe.it/files/quickburn"&gt;quickburn&lt;/a&gt;, copy it in your Nautilus scripts directory and make sure it has execution permissions. Then select some files and folders, right click and select &lt;code&gt;Scripts -&amp;gt; QuickBurn&lt;/code&gt;.&lt;/p&gt;</description>
      <pubDate>Thu, 17 Mar 2005 06:42:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:ac2bd1ce-9ebd-4270-b875-f7f6afcb805c</guid>
      <author>micampe</author>
      <link>http://blog.micampe.it/articles/2005/03/17/nautilus-quick-burner</link>
      <category>English</category>
      <category>nautilus</category>
      <category>gnome</category>
      <category>script</category>
      <category>cdrom</category>
      <category>burning</category>
      <trackback:ping>http://blog.micampe.it/articles/trackback/159</trackback:ping>
    </item>
  </channel>
</rss>
