<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>oneliner on Mister Muffin Blog</title>
    <link>http://blog.mister-muffin.de/tags/oneliner/</link>
    <description>Recent content in oneliner on Mister Muffin Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 23 Nov 2011 11:49:00 +0000</lastBuildDate><atom:link href="http://blog.mister-muffin.de/tags/oneliner/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>transposing csv for gnuplot</title>
      <link>http://blog.mister-muffin.de/2011/11/23/transposing-csv-for-gnuplot/</link>
      <pubDate>Wed, 23 Nov 2011 11:49:00 +0000</pubDate>
      
      <guid>http://blog.mister-muffin.de/2011/11/23/transposing-csv-for-gnuplot/</guid>
      <description>&lt;p&gt;I recently got a csv that was exported from openoffice spreadsheet with data
arranged in rows and not columns as gnuplot likes it. It seems that gnuplot
(intentionally) lacks the ability to parse data in rows instead of columns.
Hence I had to switch rows and columns (transpose) my input csv such that
gnuplot likes it.&lt;/p&gt;
&lt;p&gt;Transposing whitespace delimetered text can be done with awk but csv is a bit
more complex as it allows quotes and escapes. So a solution had to be found
which understood how to read csv.&lt;/p&gt;
&lt;p&gt;This turned out to be so simple and minimalistic that I had to post the
resulting oneliner that did the job for me:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;python -c&#39;import csv,sys;csv.writer(sys.stdout,csv.excel_tab).writerows(map(None,*list(csv.reader(sys.stdin))))&#39;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will read input csv from stdin and output the transpose to stdout. The
transpose is done by using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;map(None, *thelist)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another way to do the transpose in python is by using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;zip(*thelist)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But this solution doesnt handle rows of different length well.&lt;/p&gt;
&lt;p&gt;In addition the solution above will output the csv tab delimetered instead of
using commas as gnuplot likes it by using the excel_tab dialect in the
csv.writer.&lt;/p&gt;
&lt;p&gt;The solution above is problematic when some of the input values inbetween are
empty. It is not problematic because the csv would be transposed incorrectly
but because gnuplot collapses several whitespaces into one. There are several
solutions to that problem. Either, instead of an empty cell, insert &amp;ldquo;-&amp;rdquo; in the
output:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;python -c&#39;import csv,sys; csv.writer(sys.stdout, csv.excel_tab).writerows(map(lambda *x:map(lambda x:x or &amp;quot;-&amp;quot;,x),*list(csv.reader(sys.stdin))))&#39;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or output a comma delimetered cvs and tell gnupot that the input is comma
delimetered:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;python -c&#39;import csv,sys;csv.writer(sys.stdout).writerows(map(None,*list(csv.reader(sys.stdin))))&#39;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then in gnuplot:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;set datafile separator &amp;quot;,&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>converting filename charset</title>
      <link>http://blog.mister-muffin.de/2011/09/08/converting-filename-charset/</link>
      <pubDate>Thu, 08 Sep 2011 06:41:00 +0000</pubDate>
      
      <guid>http://blog.mister-muffin.de/2011/09/08/converting-filename-charset/</guid>
      <description>&lt;p&gt;So I was copying files on a vfat-formatted usb stick when this error popped up:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Invalid or incomplete multibyte or wide character
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Same issue with cp, rsync and tar. So I just thought this would be an issue
with stupid vfat so I mkfs.ntfs the drive and tried again - same issue.&lt;/p&gt;
&lt;p&gt;So while I thought that at least NTFS would allow any character except NULL
I was proven wrong. Looking it up in wikipedia indeed yielded that ntfs
file names are limited to UTF-16 code points - in contrast to ext2/3/4,
reiserfs, Btrfs, XFS and surely even more which allow any byte except NULL.&lt;/p&gt;
&lt;p&gt;So what my files contained was a number of iso 8859-1 or latin1 characters
like 0xe8 (è), 0xe0 (à), 0xf9 (ù) or 0xec (ì). It might also have been
Windows-1252 but apparently the bytes between 0x80 and 0x9F didnt appear.&lt;/p&gt;
&lt;p&gt;This is how to finally batch-convert character sets in filenames:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;convmv -f latin1 -t utf8 --notest *.flac
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>audio conversion, splitting, tagging</title>
      <link>http://blog.mister-muffin.de/2011/09/07/audio-conversion-splitting-tagging/</link>
      <pubDate>Wed, 07 Sep 2011 15:44:00 +0000</pubDate>
      
      <guid>http://blog.mister-muffin.de/2011/09/07/audio-conversion-splitting-tagging/</guid>
      <description>&lt;p&gt;I had some operas lying around amongst others Wagner&amp;rsquo;s &amp;ldquo;Ring Des Nibelungen&amp;rdquo;,
Puccini&amp;rsquo;s &amp;ldquo;La Boheme&amp;rdquo; and Verdi&amp;rsquo;s &amp;ldquo;La Traviata&amp;rdquo;. Sadly, some of them were not
stored as flac but as monkey&amp;rsquo;s audio (extension .ape) which is a non-free
lossless codec but fortunately ffmpeg has a GPL&amp;rsquo;d decoder included.
Additionally some CD&amp;rsquo;s were stored as a single file with a cue sheet next to
them.&lt;/p&gt;
&lt;p&gt;So my task was: convert ape to flac, split audio by information from cue files
and tag everything correctly.&lt;/p&gt;
&lt;p&gt;These were the lines I used to split the audio:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ffmpeg -i CD1.ape CD1.wav
shnsplit -o flac -f CD1.cue -t &amp;quot;%a %n %t&amp;quot; CD1.wav
rm *pregap.flac CD1.wav CD1.ape
cuetag CD1.cue *.flac
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;First ape is converted to wav so that shnsplit can read it. Shnsplit will then
take the timing information from the cue sheet and split the wav into chunks
which it conveniently also converts to flac on the fly. Sadly it doesnt do
tagging of those files so this is done by cuetag afterward with information
from the cue sheet. You need the shntool and cuetools packages.&lt;/p&gt;
&lt;p&gt;Other data was already existing as separate tracks and only had to be
converted from ape to flac. Sadly flac offers no means for batch conversion
but using a for loop and basename the same effect is created. Conveniently
ffmpeg will copy the tags from the ape files to the new flac files as well.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for f in *.ape; do b=`basename $f .ape`; ffmpeg -i &amp;quot;$b&amp;quot;.ape &amp;quot;$b&amp;quot;.flac; done
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The resulting flac files were about 3-5% larger than the ape files which is
a totally acceptable tradeoff for being able to ditch an unfree format.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://www.gstaedtner.net/&#34;&gt;thomasg&lt;/a&gt; pointed out to me, that using the zsh
there is an even neater way to do this loop without basename(1) and without
some shell-loop keywords:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for f in *.ape; ffmpeg -i $f $f:r.flac
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>converting base64 on the commandline</title>
      <link>http://blog.mister-muffin.de/2011/09/03/converting-base64-on-the-commandline/</link>
      <pubDate>Sat, 03 Sep 2011 20:11:00 +0000</pubDate>
      
      <guid>http://blog.mister-muffin.de/2011/09/03/converting-base64-on-the-commandline/</guid>
      <description>&lt;p&gt;There is an interesting amount of ways to do that. First line is encoding,
second line is decoding.&lt;/p&gt;
&lt;p&gt;using python:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;python -m base64 -e &amp;lt; infile &amp;gt; outfile
python -m base64 -d &amp;lt; infile &amp;gt; outfile
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;using openssl (-a is short for -base64):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;openssl enc -a -e &amp;lt; infile &amp;gt; outfile
openssl enc -a -d &amp;lt; infile &amp;gt; outfile
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;using base64 (part of the coreutils package):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;base64 &amp;lt; infile &amp;gt; outfile
base64 -d &amp;lt; infile &amp;gt; outfile
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;using perl:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;perl -MMIME::Base64 -ne &#39;print encode_base64($_)&#39; &amp;lt; infile &amp;gt; outfile
perl -MMIME::Base64 -ne &#39;print encode_base64($_)&#39; &amp;lt; infile &amp;gt; outfile
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;using uuencode (but adds a header and footer):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uuencode -m - &amp;lt; infile &amp;gt; outfile
uudecode &amp;lt; infile &amp;gt; outfile
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>convert mailman archive to mbox</title>
      <link>http://blog.mister-muffin.de/2011/07/26/convert-mailman-archive-to-mbox/</link>
      <pubDate>Tue, 26 Jul 2011 11:36:00 +0000</pubDate>
      
      <guid>http://blog.mister-muffin.de/2011/07/26/convert-mailman-archive-to-mbox/</guid>
      <description>&lt;p&gt;The mailman mailing list manager allows to download monthly archives in &amp;ldquo;Gzip&amp;rsquo;d
Text&amp;rdquo; format. This format is not mbox but can easily be turned into it by the
following simple line of sed:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sed &#39;s/^\(From:\? .*\) \(at\|en\) /\1@/&#39;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This makes it much easier to browse paste emails of an archive eg. using mutt
or reply to past emails with a proper Message-ID as to not break threads.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>text to speech</title>
      <link>http://blog.mister-muffin.de/2011/05/21/text-to-speech/</link>
      <pubDate>Sat, 21 May 2011 02:44:00 +0000</pubDate>
      
      <guid>http://blog.mister-muffin.de/2011/05/21/text-to-speech/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m planning to go biking and swimming again in the summer. What bugs me about
it, is that during both activities I can&amp;rsquo;t do much more than just that. I can&amp;rsquo;t
work on my projects or read a book. What I could do is listen to music or to a
audio book. But what I would really like to do most is to continue reading my
Perry Rhodan books. There are audio recordings of them but unfortunately those
are edited and not a 1:1 copy of the books. But since my goal was to really
read all of the books without leaving anything out this was unacceptable.&lt;/p&gt;
&lt;p&gt;My idea was to see how far we are in terms of text to speech synthesizers. To
increase the requirements I was looking for a good German synthesizer since the
Perry Rhodan novels are written in German. After some search I found out that
apparently a company called &lt;a href=&#34;http://www.ivona.com&#34;&gt;ivona&lt;/a&gt; is currently
providing the best possible solution for my problem.&lt;/p&gt;
&lt;p&gt;But of course there were additional issues. First, this company of course
doesn&amp;rsquo;t release their product for linux so I had two options: installing
windows in qemu and running their software there or seeing if I could find out
how I could find a new purpose for their online demo application.&lt;/p&gt;
&lt;p&gt;While I was setting up an emulated Windows XP in the background I tried to
figure out how the webfrontend of ivona.com was working. After a few hours of
trial and error I got the solution which in contrast to my initial believe did
not even require any reverse engineering of flash binaries.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;string=&amp;quot;Wenn die Testpiloten und Spezialisten des Linearkommandos von dem
neuartigen Kompensationskonverter zur Errichtung eines aus Sechsdimensional
übergeordneten Feldlinien bestehenden Kompensatorfeldes sprachen, dann gab sich
niemand mehr die Mühe, die zungenbrecherischen Begriffe exakt auszusprechen.&amp;quot;;
mplayer `curl --data-urlencode &amp;quot;tresc=$string&amp;quot; --data synth=1
--data chk=\`echo -n $string | perl -pe	&#39;use MIME::Base64;
$_=MIME::Base64::encode($_);tr/\+\/=/-_./;s/\n//g&#39;\` --data voice=20
--header &amp;quot;X-Requested-With: XMLHttpRequest&amp;quot;
http://www.ivona.com/index.php | sed &amp;quot;s/.*loadAudioFile(&#39;\(.*\)&#39;).*/\1/&amp;quot;`
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The X-Requested-With header is required and instead of 20, the voice POST
parameter can become 21 for a female German voice. Other numbers are for other
languages.&lt;/p&gt;
&lt;p&gt;Interestingly enough, the 250 character limit seems to be only enforced on the
client side. As one can see with the request above it is no problem at all to
convert phrases with more characters as well. Instead the server will just stop
converting at a random point. It will be around 23-26 seconds of speech or
180-200 KB. But maybe this is useful anyways for somebody.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>silent ssh-keygen</title>
      <link>http://blog.mister-muffin.de/2011/03/25/silent-ssh-keygen/</link>
      <pubDate>Fri, 25 Mar 2011 22:01:00 +0000</pubDate>
      
      <guid>http://blog.mister-muffin.de/2011/03/25/silent-ssh-keygen/</guid>
      <description>&lt;p&gt;I sometimes have to tell friends to connect to me via ssh to get some files or
similar things but they mostly did not yet generate a private/public keypair
for themselves.&lt;/p&gt;
&lt;p&gt;So for me to remember the command to generate that in the standard place
without requiring any user input that would just confuse them here is the
command:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N &amp;quot;&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>download from loombo</title>
      <link>http://blog.mister-muffin.de/2011/03/24/download-from-loombo/</link>
      <pubDate>Thu, 24 Mar 2011 07:58:00 +0000</pubDate>
      
      <guid>http://blog.mister-muffin.de/2011/03/24/download-from-loombo/</guid>
      <description>&lt;p&gt;I currently use &lt;a href=&#34;http://watchseries.eu&#34;&gt;http://watchseries.eu&lt;/a&gt; to check out some series I later might
watch in full in better quality. It provides links to several offerings from
video streaming web services of a whole lot of series. One of them is
megaupload and a howto download from there will follow but this article is
about a quick one-liner to download from &amp;ldquo;loombo.com&amp;rdquo; which has the advantage
that in contrast to megavideo there is no daily limit imposed. The &lt;code&gt;sleep 6&lt;/code&gt; is
important as the webserver seems to use that delay to make sure a human is
clicking a button after that timeout and not a machine as doing it. The id
variable comes from the url of the loombo video you want.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;id=0ioy51cxit1b; wget `curl --silent --data &amp;#34;op=download2&amp;amp;id=$id&amp;amp;rand=\`curl \
--silent http://loombo.com/$id | sed -ne &amp;#39;s/&amp;lt;input type=\&amp;#34;hidden\&amp;#34; \
name=\&amp;#34;rand\&amp;#34; value=\&amp;#34;\(\w\+\)\&amp;#34;&amp;gt;/\1/p&amp;#39;; sleep 6\`&amp;#34; http://loombo.com/$id | \
sed -ne &amp;#34;s/s1.addVariable(&amp;#39;file&amp;#39;,&amp;#39;\(\S\+\)&amp;#39;);/\1/p&amp;#34;`
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    
  </channel>
</rss>
