<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>insane innovations from a sane insanity</description><title>From bit to a heart beat</title><generator>Tumblr (3.0; @emotionull)</generator><link>http://jon.is.emotionull.com/</link><item><title>The "Search" key in Chromebook is actually a "Super" key!</title><description>&lt;p&gt;My Chromebook is becoming my main traveling machine when I am road tripping with &lt;a href="http://www.bugsense.com"&gt;BugSense&lt;/a&gt;, because is light, with more than 7 hours of battery, excellent keyboard and is running ubuntu (with everything working) :D&lt;/p&gt;
&lt;p&gt;The only problem I had, was that I usually change the Caps lock key to a Ctrl key (yes, I use emacs!). Try it and you&amp;#8217;ll see that is feels more natural having a Ctrl key placed right next to your pinky finger.&lt;/p&gt;
&lt;p&gt;In Ubuntu, it is just a click (make Caps lock behave like Ctrl) but it didn&amp;#8217;t work because the &amp;#8220;Search&amp;#8221; key is actually a SuperKey (or Windows key if you like).&lt;/p&gt;
&lt;p&gt;So, if you want to make it work, change do this:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_luo5qlb9Ml1qzwgoe.png"/&gt;&lt;/p&gt;
&lt;p&gt;and you are ready to go!&lt;/p&gt;
&lt;p&gt;- Jon&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/12802437344</link><guid>http://jon.is.emotionull.com/post/12802437344</guid><pubDate>Mon, 14 Nov 2011 23:18:03 +0200</pubDate></item><item><title>Twits to Music</title><description>&lt;p&gt;I&amp;#8217;ve created a new live programming language (built using Clojure and Processing) for creating music on the fly, called &lt;a href="http://mad.emotionull.com"&gt;music as data&lt;/a&gt; (MAD) and I am going to present it at &lt;a href="http://swdc-central.com/dyncon2011/"&gt;Dynamic Languages 2011 conference&lt;/a&gt; in Sweden. So I was thinking ways that I could demonstrate the main principle of the language that music is code is data and I thought &amp;#8220;Hey lets transform twits to music&amp;#8221;!&lt;/p&gt;
&lt;p&gt;And here we are! Every twit (mention) to @jonromero, will be converted to music and played (you can hear short examples at &lt;a href="http://mad.emotionull.com"&gt;mad.emotionull.com&lt;/a&gt;) and the final piece will be played after my talk.&lt;/p&gt;
&lt;p&gt;Let&amp;#8217;s dive into code snippets now:&lt;/p&gt;
&lt;p&gt;We are going to use &lt;a href="https://github.com/mattrepl/clojure-twitter"&gt;clojure-twitter&lt;/a&gt; for getting mentions.&lt;/p&gt;
&lt;script src="https://gist.github.com/862025.js?file=get-last-mentions.clj"&gt;&lt;/script&gt;&lt;p&gt;And then convert characters to notes.&lt;/p&gt;
&lt;script src="https://gist.github.com/862030.js?file=text-to-notes.clj"&gt;&lt;/script&gt;&lt;p&gt;You can hear an example at &lt;a href="http://mad.emotionull.com"&gt;mad.emotionull.com&lt;/a&gt; and actually has a nice beat!&lt;/p&gt;

&lt;p&gt;I also plan to map a markov-chains function so the final music can make more sense but hey, the code is &lt;a href="https://github.com/jonromero/music-as-data"&gt;online&lt;/a&gt;, clone, use and create!&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/3829982181</link><guid>http://jon.is.emotionull.com/post/3829982181</guid><pubDate>Sun, 13 Mar 2011 14:58:17 +0200</pubDate><category>clojure</category><category>music</category><category>live-programming</category><category>processing</category><category>mad</category></item><item><title>Can we disrupt music collaboration?</title><description>&lt;p&gt;I&amp;#8217;ve created &lt;a href="http://mad.emotionull.com/"&gt;music-as-data&lt;/a&gt; because I really hated trying to write about sins, freqs etc all the time in order to produce a single note. Also, it was very difficult to add abstraction and extend AND having fun all at the same time. I think that &lt;a href="http://mad.emotionull.com/"&gt;(music [as data])&lt;/a&gt; is disruptive in how we think and interact/transform music. Or maybe not. &lt;/p&gt;
&lt;p&gt;So, one of the main advantages of having music as data as code, is that we can have our music commited to version control systems. So, what would happen if we form bands that are only using code to create music, and can fork, revert and exchange music snippets? Wouldn&amp;#8217;t that be awesome? Well, who knows? It surely sound interesting.&lt;/p&gt;
&lt;p&gt;This is a call to wannabe rockstars: Get music-as-data, create a repository in github, get your friends together and (why not?) form the first EmacsBand. Who knows? You might even become a GuitarHero game. Or maybe not.&lt;/p&gt;
&lt;p&gt;Love to hear your feedback @jonromero&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/3829227631</link><guid>http://jon.is.emotionull.com/post/3829227631</guid><pubDate>Sun, 13 Mar 2011 13:39:37 +0200</pubDate><category>clojure</category><category>music-as-data</category><category>music</category><category>collaboration</category></item><item><title>Music as Data (MAD) - Live programming music in Clojure</title><description>&lt;p&gt;&lt;span&gt;
&lt;p&gt;I’ve created a new live programming language (built using Clojure and Processing) for creating music on the fly, called &lt;a href="http://mad.emotionull.com/"&gt;Music As Data&lt;/a&gt; (MAD) and I am going to present it at &lt;a href="http://swdc-central.com/dyncon2011/"&gt;Dynamic Languages 2011 conference&lt;/a&gt; in Sweden. It&amp;#8217;s fun and I think it&amp;#8217;s easier to grasp than SuperCollider, Chuck etc. Also, it&amp;#8217;s trivial to extend. And its using Processing (so you can add nice cool visual effects).&lt;/p&gt;
&lt;p&gt;So, if you are trying to use it, go to the website and twit your ideas @jonromero.&lt;/p&gt;
&lt;p&gt;Have fun, create masterpieces!&lt;/p&gt;

&lt;/span&gt;&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/3763284693</link><guid>http://jon.is.emotionull.com/post/3763284693</guid><pubDate>Thu, 10 Mar 2011 15:58:44 +0200</pubDate><category>clojure</category><category>live programming</category><category>mad</category><category>processing</category></item><item><title>Twits to @jonromero, translated to music and played using...</title><description>&lt;embed type="application/x-shockwave-flash" src="http://assets.tumblr.com/swf/audio_player_black.swf?audio_file=http://www.tumblr.com/audio_file/3763336069/tumblr_lhuhq7yMPZ1qzxcdl&amp;color=FFFFFF" height="27" width="207" quality="best" wmode="opaque"&gt;&lt;/embed&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Twits to @jonromero, translated to music and played using M.A.D &lt;/p&gt;
&lt;p&gt;&lt;span&gt;(&lt;span class="fn"&gt;play!&lt;/span&gt; (&lt;span class="fn"&gt;text-to-notes&lt;/span&gt; (&lt;span class="fn"&gt;get-latest-twits&lt;/span&gt;)))&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Twit @jonromero and have your message converted to music!&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/3763336069</link><guid>http://jon.is.emotionull.com/post/3763336069</guid><pubDate>Thu, 10 Mar 2011 08:03:43 +0200</pubDate></item><item><title>Clojure wrapper for OpenKinect!</title><description>&lt;p&gt;We are working with the guys from &lt;a href="http://niobiumlabs.com/"&gt;NiobiumLabs&lt;/a&gt; for some cool Kinect installations, so I&amp;#8217;ve started hacking around with OpenKinect.&lt;/p&gt;
&lt;p&gt;The main problem is the libraries. You must download, configure and compile a lot of stuff (I really don&amp;#8217;t know what I was going to do without apt-get) and finally all I was missing was a REPL. &lt;/p&gt;
&lt;p&gt;I had the Java (processing version) working nicely (after alot of config and &lt;em&gt;ln -s&lt;/em&gt; hacks), so I started working on a Clojure version. &lt;/p&gt;
&lt;p&gt;The advantage of having a REPL is HUGE. You can play around, experiment and test many libraries on-the-fly.&lt;/p&gt;
&lt;p&gt;So, I&amp;#8217;ve requested a pull from the main openkinect branch and I&amp;#8217;ll continue working on the clojure branch and give it some Lisp love. And all needed libraries are included (so you can start hacking RIGHT away).&lt;/p&gt;
&lt;p&gt;Follow me around (and bug me!) @jonromero!&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/2976420510</link><guid>http://jon.is.emotionull.com/post/2976420510</guid><pubDate>Fri, 28 Jan 2011 17:43:54 +0200</pubDate></item><item><title>Using python and Oracle on Ubuntu</title><description>&lt;p&gt;First of all, download &lt;a href="http://www.oracle.com/technetwork/database/express-edition/downloads/index.html"&gt;Oracle Database 10g Express Edition&lt;/a&gt; (around 200MB) after you complete a free registration for Ubuntu.&lt;/p&gt;
&lt;p&gt;If you don&amp;#8217;t have 1GB of swap, then you cannot continue with the installation unless you create some:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;$ sudo dd if=/dev/zero of=/swpfs1 bs=1M count=1000&lt;br/&gt;$ sudo mkswap /swpfs1&lt;br/&gt;$ sudo swapon /swpfs1&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(taken from &lt;a href="http://www.cyberciti.biz/faq/howto-install-linux-oracle-database-xe-server/"&gt;here&lt;/a&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then after the installation is completed, you can install the python library (cx_Oracle) via easy_install. But before that, you must export some vars (taken from &lt;a href="http://catherinedevlin.blogspot.com/2008/06/cxoracle-and-oracle-xe-on-ubuntu.html"&gt;here&lt;/a&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;$ export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server&lt;br/&gt;$ export LD_LIBRARY_PATH=$ORACLE_HOME/lib&lt;br/&gt;$ export PATH=$ORACLE_HOME/bin:$PATH&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;$ sudo -E easy_install cx_Oracle&lt;/span&gt;&lt;/p&gt;
&lt;br/&gt;&lt;span&gt;After that, you are ready to &lt;em&gt;import cx_Oracle&lt;/em&gt; and hack away!&lt;/span&gt;</description><link>http://jon.is.emotionull.com/post/1592336328</link><guid>http://jon.is.emotionull.com/post/1592336328</guid><pubDate>Tue, 16 Nov 2010 19:33:22 +0200</pubDate><category>python</category><category>oracle</category></item><item><title>Don't install slime via apt-get (at least for Clojure)</title><description>&lt;p&gt;I had huge problems with my .emacs setup when I moved it to an Ubuntu 10.10 box. I could connect with slime-connect to my swank server but I couldn&amp;#8217;t eval anything. I was going ballistic for a couple of hours (I have my .&lt;a href="http://bitbucket.org/jonromero/my-emacs/src"&gt;emacs setup&lt;/a&gt; on bitbucket and it works perfectly) until I tried to connect remotely to the swank server (so I could at least blame the server).&lt;/p&gt;
&lt;p&gt;But remotely everything kept working. So, it was something else. After A LOT of hacking around, I found that having installed slime via apt-get, puts you in the heisenbug land.&lt;/p&gt;
&lt;p&gt;So, you can either install slime via a patched version of package (&lt;a href="https://github.com/technomancy/package.el"&gt;&lt;a href="https://github.com/technomancy/package.el"&gt;https://github.com/technomancy/package.el&lt;/a&gt;&lt;/a&gt;) OR &lt;/p&gt;

&lt;script src="https://gist.github.com/4.js?file=slime.sh"&gt;&lt;/script&gt;&lt;p&gt;and then add it to your .emacs&lt;/p&gt;
&lt;p&gt;(add-to-list &amp;#8216;load-path &amp;#8220;~/opt/slime&amp;#8221;)&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/1574385743</link><guid>http://jon.is.emotionull.com/post/1574385743</guid><pubDate>Sun, 14 Nov 2010 21:48:08 +0200</pubDate></item><item><title>Installing Clojure in Ubuntu 10.10 [the easy way]</title><description>&lt;p&gt;Installing Clojure in Ubuntu can be found in a lot of places and that&amp;#8217;s the bad thing. A lot of copy/paste and things that are out of date (like Java). I&amp;#8217;ve been installing Clojure in a couple of Amazon servers for a cluster, so I gathered ALL the info in one big-huge line.&lt;/p&gt;
&lt;p&gt;What this line does:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Installs add-apt-repository (so we can add Sun’s Java 6 JDK - it&amp;#8217;s not available by default)&lt;/li&gt;
&lt;li&gt;Installs ant, git, clojure and clojure-contrib (from sources), compiles them and installs lein&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;You only have to hit &amp;#8220;y&amp;#8221; and choose &amp;#8220;ok&amp;#8221; and &amp;#8220;Yes&amp;#8221; on a couple of screens during installation. Also, choose the java-6-sun when prompted (not the java-6-open sdk). Then, you just chill out and you are ready to go!&lt;/p&gt;
&lt;p&gt;Here&amp;#8217;s the bash line you can copy and paste in your terminal:&lt;/p&gt;
&lt;script src="https://gist.github.com/674337.js?file=clj_on_ubuntu1010.sh"&gt;&lt;/script&gt;&lt;p&gt;If you found and better/smarter way, I&amp;#8217;ll be glad to hear about it!&lt;/p&gt;
&lt;p&gt;Oh, thanks to &lt;a target="_self" href="http://riddell.us/ClojureOnUbuntu.html"&gt;&lt;a href="http://riddell.us/ClojureOnUbuntu.html"&gt;http://riddell.us/ClojureOnUbuntu.html&lt;/a&gt;&lt;/a&gt; for the excellent tutorial on how to install Clojure.&lt;/p&gt;
&lt;p&gt;Coming next, installing Emacs with Clojure [the easy way]&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/1553249274</link><guid>http://jon.is.emotionull.com/post/1553249274</guid><pubDate>Fri, 12 Nov 2010 18:53:00 +0200</pubDate></item><item><title>Starting ubuntu 10.10 (64bit) on Amazon EC2</title><description>&lt;p&gt;&lt;span&gt;Instead of searching around AMI&amp;#8217;s, Ubuntu&amp;#8217;s &lt;a title="here" target="_self" href="http://aws.amazon.com/amis/4350?_encoding=UTF8&amp;amp;jiveRedirect=1"&gt;here&lt;/a&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You can search with this is id (for West Europe): ami-505c6924&lt;/span&gt;&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/1551337424</link><guid>http://jon.is.emotionull.com/post/1551337424</guid><pubDate>Fri, 12 Nov 2010 12:13:00 +0200</pubDate><category>ubuntu</category><category>amazon</category></item><item><title>Convert date to sql date in Clojure</title><description>&lt;p&gt;It seems simple (everything is simple after you&amp;#8217;ve seen the solution) but couldn&amp;#8217;t find a post so here it goes:&lt;/p&gt;
&lt;script src="https://gist.github.com/669460.js?file=current_date_to_sql.clj"&gt;&lt;/script&gt;</description><link>http://jon.is.emotionull.com/post/1526140025</link><guid>http://jon.is.emotionull.com/post/1526140025</guid><pubDate>Tue, 09 Nov 2010 19:43:22 +0200</pubDate></item><item><title>Create a web service in Clojure without start/stopping the server</title><description>&lt;p&gt;&lt;em&gt;This is a cross-post from &lt;a target="_blank" href="http://blog.socialcaddy.com/create-web-service-in-clojure-without-startst"&gt;SocialCaddy&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The problem using Jetty (or Netty or Ring) is that after you start the process, your beloved REPL is &amp;#8220;binded&amp;#8221; to the server thus forcing you to kill the service, make a change, start the process again, refresh and do it again. Not fun at all. It&amp;#8217;s easy to run the process &amp;#8220;in the background&amp;#8221; and have the REPL available to make changes. &lt;/p&gt;
&lt;p&gt;Let&amp;#8217;s create a new project (using lein).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;gt; lein new TinyService&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now, we need  a project.clj (so we can do a lein deps and have everything installed automagically)&lt;/p&gt;
&lt;p&gt;
&lt;script src="http://gist.github.com/481262.js?file=project.clj"&gt;&lt;/script&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;gt; lein deps&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Edit core.clj with this:&lt;/p&gt;
&lt;p&gt;
&lt;script src="http://gist.github.com/481266.js?file=core.clj"&gt;&lt;/script&gt;&lt;/p&gt;
&lt;p&gt;You can run the service in REPL by (boot) and then you&amp;#8217;ll still have access to REPL. You can change stuff, C+c C+c, refresh and voila! You can even connect to web server (to a JVM to be more exact) and make changes without the need for compilation. And all this from your local emacs!&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/831673339</link><guid>http://jon.is.emotionull.com/post/831673339</guid><pubDate>Mon, 19 Jul 2010 14:17:37 +0300</pubDate><category>emacs</category><category>clojure</category></item><item><title>"Having a developer write his own unit tests is like asking a crazy man if he’s sane."</title><description>“Having a developer write his own unit tests is like asking a crazy man if he’s sane.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;reddit&lt;/em&gt;</description><link>http://jon.is.emotionull.com/post/634943883</link><guid>http://jon.is.emotionull.com/post/634943883</guid><pubDate>Wed, 26 May 2010 20:30:23 +0300</pubDate></item><item><title>Activerecord in Python: Do it like Rails!</title><description>&lt;p&gt;I&amp;#8217;ve searched around the net for a nice, clean implementation of activerecord in Python but I found none. There are many better libraries for database abstraction out there in Python but I think that Rails&amp;#8217; &amp;#8220;activerecord&amp;#8221; way is a breeze and a fun way to access a database.&lt;/p&gt;
&lt;p&gt;So, my weekend project was to see whether I could hack together a small activerecord for Python.&lt;/p&gt;
&lt;p&gt;The first thing I reeeeaally wanted to do, is to create dynamic queries. What dynamic queries are you ask.&lt;/p&gt;
&lt;p&gt;Let&amp;#8217;s say you have a database and a table with some &lt;strike&gt;fruits&lt;/strike&gt; fields.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Table: People&lt;/p&gt;
&lt;p&gt;Fields: id, name, sex&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Using ActiveRecord you can do this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;user = People.find_by_name(&amp;#8220;Robert&amp;#8221;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;and you&amp;#8217;ll get all the People with the name Robert. The magic thing is that you haven&amp;#8217;t defined anywhere the function find_by_name. Activerecord has only the function find_by and depending on your search it creates automatically a new function called find_by_name (if the &amp;#8216;name&amp;#8217; field exists on your table). This is all thanks to Ruby&amp;#8217;s method_missing function.&lt;/p&gt;
&lt;p&gt;Ruby&amp;#8217;s method_missing is called automatically from ruby&amp;#8217;s VM everytime a function you tried to call was not found. So, when you called find_by_name, ruby couldn&amp;#8217;t find the function and after all the search it went to method_missing. From there, activerecord took control and done it&amp;#8217;s magic.&lt;/p&gt;
&lt;p&gt;That are many different ways to do it in Python but only one comes close to Rails&amp;#8217; implementation.&lt;/p&gt;
&lt;p&gt;Behold:&lt;b&gt; __getattr__&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Everytime you call a class attribute, this function is called. So, in Python:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;user = User.find_by_name(&amp;#8220;Robert&amp;#8221;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;calls __getatr__ and if the attribute does not exist, it throws an &amp;#8216;AttributeError&amp;#8217; exception. That&amp;#8217;s the place we are going to put our code and create the dynamic queries.&lt;/p&gt;
&lt;p&gt;The most difficult part was this: The function __getattr__ gets one parameter (the attribute) so in this example it was the &lt;b&gt;find_by_name&lt;/b&gt;. I had to find a way to pass to __getattr__ the query&amp;#8217;s argument.&lt;/p&gt;
&lt;p&gt;Behold: &lt;b&gt;Lambda&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;I know a hobby project of mine is awesome when I have to use lambda (old habits from C and Lisp). Using&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;lambda &lt;b&gt;value&lt;/b&gt;: do_smth(&lt;b&gt;value&lt;/b&gt;),&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;you open up the way for another parameter to join the game (hint: &lt;b&gt;value&lt;/b&gt;). So, we have this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;dynamic_query = {&lt;/p&gt;
&lt;p&gt;&amp;#8220;find_by_&amp;#8221;: lambda value: self._find(field, value)&lt;/p&gt;
&lt;p&gt;}[query]&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is a dictionary emulating a switch/case in Python with lambdas. If you want to add more functions (insert,update) or more logic (find_by_name_and_sex), this is the place to hack.&lt;/p&gt;
&lt;p&gt;Check it online at &lt;a target="_blank" href="http://bitbucket.org/jonromero/pyactiverecord/"&gt;my bitbucket account&lt;/a&gt; and push your changes.&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/339111307</link><guid>http://jon.is.emotionull.com/post/339111307</guid><pubDate>Sun, 17 Jan 2010 15:33:36 +0200</pubDate><category>metaprogramming</category><category>rails</category><category>python</category><category>activerecord</category></item><item><title>Nimbuzz, Android and Skype: Put your headphones on!</title><description>&lt;p&gt;I love &lt;a href="http://nimbuzz.com/"&gt;Nimbuzz&lt;/a&gt; (loving it since I first learn about it when I was at the &lt;a target="_blank" href="http://erlang-factory.com"&gt;Erlang Factory&lt;/a&gt; in London and spoke with a guy from Nimbuzz) &amp;#8216;cause it was running smoothly on my Symbian and allowing me to connect with Skype. So when I got my HTC Hero, it was the first app I was going to install. But Skype(to Skype) didn&amp;#8217;t seem to work (couldn&amp;#8217;t speak, couldn&amp;#8217;t hear).&lt;/p&gt;
&lt;p&gt;I tried &lt;a href="http://fring.com"&gt;Fring&lt;/a&gt; where everything seemed to be working smoothly and I noticed that a headphones icon was appering on my notification bar eventhough I had no headphones connected. So, I connected my slick HTC Hero headphones, fired up Nimbuzz and tadaaaa!&lt;/p&gt;
&lt;p&gt;Maybe this solves the muted mic for the Droid on Nimbuzz. I hope for an update and video call!&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/319634186</link><guid>http://jon.is.emotionull.com/post/319634186</guid><pubDate>Wed, 06 Jan 2010 13:01:44 +0200</pubDate><category>android</category></item><item><title>Facebook Connect for web2py</title><description>&lt;p&gt;Even though web2py has support for building facebook applications, we didn&amp;#8217;t have a way to use Facebook Connect.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve studied many ways (like Facebook&amp;#8217;s Javascript API) and checked other frameworks (Rails and Django) and after 4 hours I made a patch to facebook.py that enables web2py (and I&amp;#8217;m sure that other python frameworks can use - like webpy) to use Facebook Connect by doing this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;def index():&lt;br/&gt;   connected = facebook_connect(request, facebook_settings)&lt;br/&gt;   if connected:&lt;br/&gt;       user = get_facebook_user(request.facebook)&lt;br/&gt;       response.flash = "Hello ", user        &lt;br/&gt;   return dict(api_key=facebook_settings.FACEBOOK_API_KEY)&lt;code&gt;&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;Just one line of code and you are done!&lt;/p&gt;
&lt;p&gt;You can check a live example &lt;a title="here" target="_blank" href="http://fbconnect-demo.emotionull.com/"&gt;here&lt;/a&gt; and grub the &lt;a target="_blank" href="http://github.com/jonromero/fbconnect-web2py"&gt;code&lt;/a&gt; from github&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/319023923</link><guid>http://jon.is.emotionull.com/post/319023923</guid><pubDate>Wed, 06 Jan 2010 04:37:26 +0200</pubDate><category>facebook connect</category><category>web2py</category></item><item><title>Implementing a Rails-like scaffolding in web2py (but better!)</title><description>&lt;p&gt;Sometimes I want to create a better administration panel for our clients. With this hack you can create an add/edit/delete panel for every table you like and extend it easily. in order to use it you just go inside the controllers and add:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@scaffold(None)&lt;br/&gt;def authors():&lt;br/&gt;    pass&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;this will create an admin page (authors) that has all the properties from the table &amp;#8220;authors&amp;#8221;. if you have to &amp;#8220;admin&amp;#8221; a different table just put it&amp;#8217;s name:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@scaffold("other_table")&lt;br/&gt;def authors():&lt;br/&gt;    pass&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Read the comments for more hacks. PS: I have also a new version that you can pass custom queries (I&amp;#8217;ll keep you updated). PS2: Also a version with DataTables (&lt;a href="http://datatables.net/"&gt;http://datatables.net/&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;You can also chain decorators in order to prevent unauthorized access:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@auth.requires_login()&lt;br/&gt;@scaffold("other_table")&lt;br/&gt;def authors():&lt;br/&gt;    pass&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, the installation:&lt;/p&gt;
&lt;p&gt;First, put this code inside a module (or in a separate file in models).&lt;/p&gt;
&lt;p&gt;def scaffold(tbl&lt;i&gt;name=None, field&lt;/i&gt;id=None):         &amp;#8220;&amp;#8221;&amp;#8221;         Decorator that exposes show/add/edit/delete         for admin purposes&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    You can specify a table name else it will use the&lt;br/&gt;    name of the function as table name&lt;br/&gt;    You can specify a field id that will be displayed for the record&lt;br/&gt;    else it will use the first field value&lt;br/&gt;    """&lt;br/&gt;&lt;br/&gt;    def decorator_outside(func):&lt;br/&gt;&lt;br/&gt;        def decorator_inside(*args):&lt;br/&gt;&lt;br/&gt;            db_name = db # we could get the database name from globals&lt;br/&gt;            table_name = func.__name__ if tbl_name == None else tbl_name&lt;br/&gt;            if table_name not in db_name.tables:&lt;br/&gt;                raise Exception("No table with name '%s' found" % table_name)&lt;br/&gt;&lt;br/&gt;            form = None&lt;br/&gt;            if len(request.args) &amp;gt; 1:&lt;br/&gt;                action = request.args[0]&lt;br/&gt;                record_id = request.args[1]&lt;br/&gt;&lt;br/&gt;                if action == 'create':&lt;br/&gt;                    form = crud.create(db_name[table_name])&lt;br/&gt;&lt;br/&gt;                elif action == 'show':          &lt;br/&gt;                    form = crud.read(db_name[table_name], record_id)&lt;br/&gt;&lt;br/&gt;                elif action == 'edit':          &lt;br/&gt;                    form = crud.update(db_name[table_name], record_id)&lt;br/&gt;&lt;br/&gt;                elif request.args[0] == 'delete':           &lt;br/&gt;                    form = crud.delete(db_name[table_name], record_id)&lt;br/&gt;&lt;br/&gt;            result = db_name(db_name[table_name].id &amp;gt; 0).select()       &lt;br/&gt;            func()&lt;br/&gt;&lt;br/&gt;            return dict(rows=result, cntr_name=table_name, form=form, field_id=field_id)&lt;br/&gt;        return decorator_inside&lt;br/&gt;&lt;br/&gt;    return decorator_outside&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The do the action in the controller     @scaffold(&amp;#8220;other_table&amp;#8221;)     def authors():         pass&lt;/p&gt;
&lt;p&gt;Finally create a view file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{{extend 'layout.html'}}&lt;br/&gt;{{ include 'scaffold.html' }}&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and paste this into your views folder:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{{= form if form != None else "" }}&lt;br/&gt;&amp;lt;br /&amp;gt;&lt;br/&gt;&amp;lt;table&amp;gt;&lt;br/&gt;  {{ i = 0 }}&lt;br/&gt;  {{ for row in rows: }}&lt;br/&gt;  {{ i += 1 }}&lt;br/&gt;  &amp;lt;tr class="{{='even' if i%2 else 'odd'}}"&amp;gt;&lt;br/&gt;    &amp;lt;td class='main'&amp;gt;&amp;lt;a href="{{= URL(r=request, f=cntr_name+'/show',&lt;br/&gt;                     args=row.id) }}"&amp;gt;{{= row.values()[field_id] }}&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&lt;br/&gt;    &amp;lt;td&amp;gt;&amp;lt;a href="{{= URL(r=request, f=cntr_name+'/edit',&lt;br/&gt;                     args=row.id) }}"&amp;gt;Edit&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&lt;br/&gt;    &amp;lt;td&amp;gt;&amp;lt;a href="{{= URL(r=request, f=cntr_name+'/delete',&lt;br/&gt;                     args=row.id) }}"&amp;gt;Delete&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&lt;br/&gt;  &amp;lt;/tr&amp;gt;&lt;br/&gt;  {{ pass }}&lt;br/&gt;&amp;lt;/table&amp;gt;&lt;br/&gt;&lt;br/&gt;{{ if not len(rows): }}&lt;br/&gt;No records found&lt;br/&gt;{{ pass }}&lt;br/&gt;&lt;br/&gt;&amp;lt;br /&amp;gt;&lt;br/&gt;&amp;lt;a href="{{= URL(r=request, f=cntr_name+'/create/new') }}"&amp;gt;Add new&amp;lt;/a&amp;gt;&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;</description><link>http://jon.is.emotionull.com/post/301344546</link><guid>http://jon.is.emotionull.com/post/301344546</guid><pubDate>Sat, 26 Dec 2009 17:08:00 +0200</pubDate></item><item><title>Uploading files using CKEditor in web2py</title><description>&lt;p&gt;This is the second part of integrating CKEditor in web2py. I should warn you that quotes are messed up in the blog so you can check at &lt;a target="_blank" href="http://www.web2pyslices.com/main/slices/take_slice/18"&gt;web2pyslices&lt;/a&gt; for the updated (and ready for copy-paste) version.&lt;/p&gt;
&lt;p&gt;What it needs to be done in order to have ckeditor uploading works. First, it needs a &amp;#8220;file browser&amp;#8221; url. That&amp;#8217;s just a form with an upload field where we can use to find and upload files. The think is that we must return the path of the uploaded file BACK to the parent form. The most difficult part is activating the Upload button. That is done by specifying the &amp;#8220;filebrowserBrowseUrl&amp;#8221;. So, here it goes!&lt;/p&gt;
&lt;p&gt;Let&amp;#8217;s add a new table that will hold our files:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import datetime;&lt;br/&gt;timestamp = datetime.datetime.today()&lt;br/&gt;    db.define_table('files',&lt;br/&gt;                    Field('title', 'string'),&lt;br/&gt;                    Field('uploaded_data', 'upload'),&lt;br/&gt;                    Field('created_on','datetime',default=timestamp))&lt;br/&gt;&lt;br/&gt;db.files.title.requires = IS_NOT_EMPTY()                &lt;br/&gt;db.files.uploaded_data.requires = IS_NOT_EMPTY()&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, lets add an action the our controller&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def upload_file():&lt;br/&gt;    url = ""&lt;br/&gt;&lt;br/&gt;    form = SQLFORM(db.files, showid=False)&lt;br/&gt;    if form.accepts(request.vars, session):&lt;br/&gt;        response.flash = T('File uploaded successfully!')&lt;br/&gt;        url = URL(r=request, f="download", &lt;br/&gt;                 args = db(db.files.title == request.vars.title).select(orderby=~db.files.created_on)[0].uploaded_data)&lt;br/&gt;    return dict(form=form, cknum=request.vars.CKEditorFuncNum, url=url)&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and a view upload_file.html:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{{extend 'layout.html'}}&lt;br/&gt;&lt;br/&gt;&amp;lt;h2&amp;gt;Upload file&amp;lt;/h2&amp;gt;&lt;br/&gt;{{=form}}&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;{{ if url != "": }}&lt;br/&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br/&gt;  window.opener.CKEDITOR.tools.callFunction({{=cknum}}, '{{=url}}');&lt;br/&gt;&amp;lt;/script&amp;gt;&lt;br/&gt;{{ pass }}&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, lets add the javascript files to our layout AFTER web2py_ajax.html:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; &amp;lt;script type="text/javascript" src="{{=URL(request.application,'static','js/ckeditor/ckeditor.js')}}"&amp;gt;&amp;lt;/script&amp;gt;&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, lets create a test page:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{{extend 'layout.html'}}&lt;br/&gt;&lt;br/&gt;{{=form}}&lt;br/&gt;&lt;br/&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br/&gt;  var ckeditor = CKEDITOR.replace('page_body', {&lt;br/&gt;  filebrowserBrowseUrl : "{{=URL(request.application, c='default', f='upload_file')}}",&lt;br/&gt;  //filebrowserUploadUrl : "{{=URL(request.application, c='default', f='upload_file')}}",&lt;br/&gt;});&lt;br/&gt;&amp;lt;/script&amp;gt;&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We are ready!&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/288806037</link><guid>http://jon.is.emotionull.com/post/288806037</guid><pubDate>Fri, 18 Dec 2009 13:00:41 +0200</pubDate></item><item><title>Creating unicode permalinks in Python (even from Greek!)</title><description>&lt;p&gt;Optimizing &lt;a href="http://betabug.ch/blogs/ch-athens/135"&gt;this blog post&lt;/a&gt;, which shows you how to create a greek to greeklish &amp;#8220;translator&amp;#8221;, I&amp;#8217;ve created a permalink function that creates urls from greek titles (but you can use your language).&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;
&lt;blockquote&gt;def create_permalink(s):&lt;br/&gt; &amp;#8220;&amp;#8221;&amp;#8220;&lt;br/&gt; Create greeklish permalinks.&lt;br/&gt; Also works for english.&lt;br/&gt; &amp;#8220;&amp;#8221;&amp;#8220;&lt;br/&gt; import string&lt;br/&gt; import re&lt;br/&gt;&lt;br/&gt; input_string = s.lower().decode(&amp;#8216;utf-8&amp;#8217;).encode(&amp;#8216;iso-8859-7&amp;#8217;, &amp;#8216;replace&amp;#8217;)&lt;br/&gt; from_chars = &amp;#8216;αβγδεζηθικλμνξοπρσςτυφχψωάήέίόύώϊ&amp;#8217;.decode(&amp;#8216;utf-8&amp;#8217;).encode(&amp;#8216;iso-8859-7&amp;#8217;, &amp;#8216;replace&amp;#8217;)&lt;br/&gt; to_chars = &amp;#8216;abgdezh8iklmn3oprsstufxywaheiouwi&amp;#8217;&lt;br/&gt;&lt;br/&gt; translation_table = string.maketrans(from_chars, to_chars)&lt;br/&gt; input_string = string.translate(input_string, translation_table)&lt;br/&gt;&lt;br/&gt; return re.compile(&amp;#8220;\W+&amp;#8221;, re.UNICODE).sub(&amp;#8220;_&amp;#8221;, input_string)&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;/blockquote&gt;</description><link>http://jon.is.emotionull.com/post/248260459</link><guid>http://jon.is.emotionull.com/post/248260459</guid><pubDate>Wed, 18 Nov 2009 10:28:00 +0200</pubDate></item><item><title>Using widgets in web2py (integrating CKEditor)</title><description>&lt;p&gt;Although web2py comes with an integrated editor, I really like &lt;a title="ckeditor" target="_blank" href="http://ckeditor.com/"&gt;ckeditor&lt;/a&gt; and using it for a text field is trivial using widgets!&lt;/p&gt;
&lt;p&gt;First, install ckeditor (put the ckeditor inside a js/ckeditor file in your static folder and include it)&amp;#160;:&lt;/p&gt;
&lt;blockquote&gt;&amp;lt;script type=&amp;#8221;text/javascript&amp;#8221; src=&amp;#8221;{{=URL(request.application,&amp;#8217;static&amp;#8217;,&amp;#8217;js/ckeditor/ckeditor.js&amp;#8217;)}}&amp;#8221;&amp;gt;&amp;lt;/script&amp;gt;&lt;br/&gt;&lt;/blockquote&gt;
&lt;p&gt;After that, we define a &amp;#8216;body&amp;#8217; text field (or whatever name you like):&lt;/p&gt;
&lt;blockquote&gt;db.define_table(&amp;#8216;page&amp;#8217;,&lt;br/&gt; # more Fields &amp;#8230;&lt;br/&gt; Field(&amp;#8216;body&amp;#8217;, &amp;#8216;text&amp;#8217;))&lt;/blockquote&gt;
&lt;p&gt;Then, inside your db.py (or to another file in your models directory) put the widget:&lt;/p&gt;
&lt;blockquote&gt;def advanced_editor(field, value):&lt;br/&gt; return TEXTAREA(_id = str(field).replace(&amp;#8216;.&amp;#8217;,&amp;#8217;_&amp;#8217;), _name=field.name, _class=&amp;#8217;text ckeditor&amp;#8217;, value=value, _cols=80, _rows=10)&lt;br/&gt;&lt;/blockquote&gt;
&lt;p&gt;and use the widget&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;db.page.body.widget = advanced_editor&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;From now, SQLFORM will use ckeditor to show/edit/save data!&lt;/p&gt;
&lt;p&gt;&lt;img alt="CkEditor in web2py" src="http://emotionull.com/blog_files/ckeditor-in-web2py.png" height="235" width="470"/&gt;&lt;/p&gt;</description><link>http://jon.is.emotionull.com/post/227873650</link><guid>http://jon.is.emotionull.com/post/227873650</guid><pubDate>Fri, 30 Oct 2009 14:14:08 +0200</pubDate></item></channel></rss>

