Wednesday, July 24, 2013

Amazon Cloud Reader copy to clipboard

It does not have it and I needed it.

Amazon, I do not like being lured to your store just to get my Reader highlights!

Friday, May 18, 2012

Google -

Google Drive drives me crazy...
This document is not available offline.
This resource is not available.
Stupid fake local good for nothing .gdoc files.
-1 Google!

Tuesday, April 03, 2012

merge problems with Subversion on Eclipse Indigo

Retrieval of mergeinfo unsupported

In case you get a new lightning fast i7 MBP with SSD and 8 GB of RAM and you still wonder at how fast Eclipse Indigo is loading (like instant) while you install Subclipse STOP!

First remove Subversive.
Then get the CollabNet JavaHL.
Then get Subclipse 1.6 instead of 1.8 (not so latest and greatest this one!) because 1.8 isn't really working and you probably have your working copies on 1.6 anyway.

Lesson learned...
No amount of SSD capacity and RAM can save you from Clicking before you thinking (tm)

Friday, November 18, 2011

HTML5 rocks!

Just a little insider joke for those who know what's what and what was what 10 years ago...


Thursday, November 10, 2011

Mobile flash is dead. The future is mobile!

So where the heck does that leave Flash as a platform?!
Lee urges the community to caution reasoning that
"Flash is not nearly as ubiquitous on mobile browsers as it is on the desktop"
Aral, long time parted from the mothership tweets "I told you so!".

So the future is mobile, the future is native and there's place only for HTML5 in the browser. Go figure...

In truth I haven't had a decent flash website project since 2009. I did have lots of AIR work and AJAX+HTML5 work. But then again. as a working developer you dont't really need to try to figure out the trends...
All you need to do is keep up with them ;-)

first rule of GIT

Yep, GIT rocks!
I just had to do some search and replace on a local version of a static website and I needed a way to quickly version my changes as the muti-file search and replace in TextWrangler cannot be reversed. GIT to the  rescue. I just made a local git repo of the website, a first commit, the search and replace and another commit.
I was able to make a backup before the search/replace using git archive and after the commit I used my old git diff script to export the changed files to a different folder. So my first rule of GIT is:
GIT is first and foremost a tool for you and _your_ code!

To SQL or NoSQL to...

I'm pretty fond of MySQL and I really think that paired with MySQLWorkbench it provides an unbeatable solution for your regular web development needs.
But it's hard to ignore the NoSQL crowd with their stories of sheer heroic victories over latency in deploying and scaling complex online applications. Like only yesterday I was going over this presentation of Jesper Richter Reichhelm of Wooga in which he explained how they got to 1 mil. daily users without cache. With R/W to the database. It's true that they use Redis for the high octane stuff and MySQL for the rest but still it wouldn't work without NoSQL. Much virtual ink has flown since the rise of NoSQL and here is a particularly concise piece from Kristóf Kovács on the various solutions available with their pros and cons.
But now here's Yoshinori Matsunobu of DeNA, ex. MySQL consultant coming up and claiming 750.000 qps on a commodity server using ONLY MySQL. In his investigations of MySQL vs memcached his basic conclusion is that most of the time is consumed in SQL by concurrency controls. In order to circumvent this while still using InnoDB Akira Higuchi wrote the HandlerSocket Plugin:
"HandlerSocket is a MySQL daemon plugin so that applications can use MySQL like NoSQL. The biggest purpose of the HandlerSocket is that it talks with storage engines like InnoDB without SQL-related overheads. To access MySQL tables, of course HandlerSocket needs to open/close tables. But HandlerSocket does not open/close tables every time. It keeps tables opened for reuse. Opening/closing tables is very costly and causes serious mutex contentions so it's very helpful to improve performance. Of course HandlerSocket closes tables when traffics become small etc so that it won't block administrative commands (DDL) forever."
It looks that it's almost 2x as fast as using memcached with less CPU usage. And you get to keep all the benefits of InnoDB.
Also fresh from Oracle there is the new preview release of the memcached daemon plugin which implements memcached as a MySQL plugin daemon. This has the memcached and mysql in the same process thus having very low latency and does direct access to InnoDB bypassing the SQL parser. It looks very promising!

Still I'm not saying that you should forget about NoSQL. On the contrary!
I strongly believe that as a developer you should keep all these solutions at hand. It's good to have so many options and so much shared knowledge available and it only makes it more easy to be able to provide your clients with the optimal solutions to their problems.
Rock on!

Thursday, August 25, 2011

how to check a file digest on OSX

openssl sha1 /path/to/my/file | grep -c "the_digest_to_check_against"
sould print "1".

Wednesday, August 10, 2011

OpenCV with Python on WSGI on CentOS with Plesk10

Well it all comes together rather nicely...
My old-ish saying that "If I can make it work on OSX I'll make it work anywhere!" proved true again!
In the past I managed to make Python+WSGI+OpenCV work on Snow Leopard with MacPorts. You can find the articles related to that on this very blog. It was quite a ride.
But the final goal was to get it working on a bad ass CentOS hosting server we run at the company. The problem was it came with Plesk 10. Now I won't go into a rant about Plesk. Suffice to say it's 10 because the update of 9 to 10 went horribly wrong and ended with a server move :-D
Luckily the guys at Rackspace I'm such a big fan of made the IUS Repos available for the very purpose of providing "A better way to upgrade RHEL". And that it is.

I did not update PHP using IUS because amazingly Parallels came up with a way to do that and now you can have 5.3 rather easy and not break Plesk. But Python 2.6 on CentOS is a different story.
Suffice to say that following the IUS articles I manage to have Python 2.6 and mod_wsgi quickly and painlessly running on the box.

The big problem was compiling OpenCV2 and after yumming all the required packages like python26-numpy, python26-distribute, a compiler, some image libs and make as per the OpenCV docs, the magical command was:
After that I had to copy the and into the python26 site-packages because the install put them into the dist-packages folder. Then I yummed python-setuptools and used easy_install-26 to install Werkzeug. Jaaaa!

The only remained glitch was the mod_wsgi setup with Plesk.
Plesk comes with mod_python and it acts like that's a major achievement. I simply commented everything in /etc/httpd/conf.d/python.conf and added a vhost.conf file in the Plesk domain folder. In there I pasted the basic WSGI setup including explicitly specifying the user I want the process to run under and that is the user you defined in Plesk at domain creation and who owns that folder.
The setup looks something like this:

WSGIDaemonProcess home=/var/www/vhosts/ user=YOUR_DEFINED_PLESK_USER processes=2 threads=5
WSGIScriptAlias / "/var/www/vhosts/"

<Directory "/var/www/vhosts/">
	WSGIApplicationGroup %{GLOBAL}
	Order deny,allow
	Allow from all

After nailing the Plesk extra config file with a
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain
all was up and running.

And it sure is great when that happens ;-)

Facebook Page Tab Canvas IFrame Application with CakePHP

Ahhh, the joys of Facebook development!

I remember back in 2007 when they launched _THE_ Platform. Man was it a weird thing. At the time I worked on a Flash prototype but quickly gave up. If only I would've persevered maybe Farmville would have a different owner :D
Last year I tried again. FBML, page scraping, localhost dev with port forwarding, lakes of tears...

Now it's take 3.
It definitely looks easier.
Especially after this year's shift to IFrame apps. If you dont want to look under the hood you don't. If you want to or have to, the only two not-so-easy parts are dealing with callbacks and OAuth2.0.
And as always when it comes to PHP it's time to put CakePHP to work.

But I have to admit that the Cake did it to me again...
The Session component clears the existing session when the Session.start is true in config. And it was.
So the Facebook user id was there only on IFrame load and it was deleted immediately after by the SessionComponent. Setting Session.start to false fixed it but I don't want to do that.
The solution that works is ditching the facebook.php and extending FacebookBase into a CakePHP Facebook Component. Biggest downside is the Security.level set to low so that CakeSession doesn't insist on a session.referer_check which breaks the FB flow.
The whole thing is server side only. This is mainly because at the time of the coding the PHP SDK docus clearly yelled that it is not compatible with the the to-be-updated client side JS SDK.
But it works great. Unltil they change something on FB. Btw, did anyone see the Test users tab in the Roles section that I used a while ago? Ah, there it is! Back again after a week in the countryside :-D

In the code you can also find some hints at the "Publishing to Page feed from Facebook Application" problem.
The issue was grabbing an offline auth_token for the Facebook page so that my application can make posts to the Page wall at any time. This is achieved by having a FB permission section in the admin where the admin who also is an admin of the FB page can initiate the access_token request. The component's updatePageAccessToken method is called and that redirects the user to the FB login and then App permissions pages so that after a successful flow Facebook calls back the UsersController admin_facebookPermissions method that checks the component getPageAccessToken() and stores it if it's there.

Although the component is not a Swiss Army knife for Cake Facebook development I think it's worth sharing. It's not a plugin so not as plug and play as some may desire but it can be used without major hassles.

Questions are as always welcomed.

Thursday, June 30, 2011

what panel? OpenPanel!

"OpenPanel offers all basic hosting services for setting up domains, including DNS, email, websites and databases. A layered authentication system allows the administrator to create accounts with specified limitations for end-users. All of the system’s users are able to control system configuration using either an intuitive graphical interface or a powerful command line configuration shell."

Friday, June 24, 2011

for bigger problems use a smarter hammer

PHP won't detect faces anymore. The OpenCV extension does not support the last PHP and I'm sick of using a small screwdriver to put big nails in place. I will build a set of utility APIs that can be used by all my web apps. They will run on Python and I'll tame the snake using a lightweight framework.
Enter the perfect Python wsgi hammer:

Werkzeug, das
Wortart: Substantiv, Neutrum
Worttrennung: Werk|zeug
Gesamtheit von Werkzeugen, die für eine Arbeit gebraucht werden
After a couple of hours of getting familiar with the tool and going trough the tutorial I figured out that for now I only need the HTTP utilities and a base application.wsgi with all the code inside will do. If you want to go deeper I recommend looking at this to-do sample app. It's a really good example of how to run it on wsgi and is simple enough to grasp but still uses all the stuf you would normally need like DB and persistence.
Now I'm convinced that is order to learn a new programming language is better to study a framework and not a book. Because a popular framework with all the resources already available is really the best cookbook you can get. Sure you need to familiarize yourself with the syntax of the language but if you go trough the simple tutorial you're more than half way there.
Hammer on!

Tuesday, May 10, 2011

StageVideo in Adobe AIR 2.6


My carefully crafted title describes a thing that does not exist.
You can get it only on AIR for TV. And I bet your hardware specs do not contain such exotic devices!
And another bummer is that AIR 2.7 won't have it either.

So what can you do?

Well if the thing you're building has a mouse and asking the user to initiate Full Screen is acceptable you can try this.

If you can choose the hardware you have a really good chance with a combo of ARI 2.6, Windows, H.264 and one of the Nvidia cards that support H.264 hw accelerated decoding with Flash. 
On Mac you will need OSX 10.6.3+ with NVIDIA GeForce 9400M, GeForce 320M or GeForce GT 330M.

My tests on WinXP with a Quadro FX card were really promising. Running AIR in Full Screen while playing the Fast Five 1080p Trailer 2 file was smooth and took only 50% CPU. Same as Quicktime Player actually.
Testing on Mac was not that promising. On a MBP 13'' with a GeForce 320M CPU was around 100% and the playback was bad. I guess that for now my goal of using Mac Mini as the base hardware for a video kiosk won't happen.

So the conclusion for now is that you can get fast HD video playback in Adobe AIR on any screen across all desktop devices as long as the video is H.264, the device has a specific video card and it runs Windows.

Ford be praised!

Update 16.05.2011:
Some more thoughts about H.264 playback on OSX...
If your client is of the cool enterprise kind and loves Mac Minis then you really want to deliver.
So you do some more testing, coding with one hand and keeping your fingers crossed on the other.
I tried the new wonder kid on the block, the Titanium Desktop from Appcelerator. Simple thing to do, really. Just put a HTML5 video tag in the Resources/index.html file and point it to your local video file. But the performance was daunting. CPU was around 100% but playback was choppy as hell. Maybe it can't deal with dual cores properly...
Since I already had the html file I dragged it into Safari for old times sake.
Now that's the life... 70% CPU max. Smooth as silk. Like coming home. I almost fired up XCode and learned Objective C :-)
A final word on this. I tried the AIR 2.6 sample app on a Mac Mini with the NVidia 320M. CPU was around 140% but playback was smooth on all 3 tryouts. Also on my not so new MBP with it's GeForce 8600M GT playback was smooth after a fresh reboot with around 165% CPU. The same video at 720p had excellent playback and good image quality with max 110% CPU on my MBP.
So I'd say that this would also be an acceptable solution: use AIR on the Mac Mini, lower the encoding to 720p in case the playback is unsatisfactory and update your app to StageVideo + 1080p once StageVideo becomes available on Adobe AIR.

Update 10.11.2011:
Adobe AIR 3 is out and still no StageVideo for the desktop. But at least we're rid of Flash for mobile. That shows some progress :-D
However the AIR 3.2 Beta on Labs does have multi-threaded video decoding which "should improve the overall performance on all platforms". Hmmm...

The JavaScript Trap

Important notice for free software supporters using Gmail!
"Are you using Gmail? Nearly 50% of the FSF's 40,000 strong supporter mailing list has an email address.
Because of the incredibly high percentage of Gmail-using free software supporters, we're taking action to raise awareness about how to use Gmail without using proprietary software. We'll also be working on longer term solutions, but the most immediate positive step to take is to stop running the proprietary programs."
The Free Software Foundation 
Take action!

To be, or not to be, that is the question...

Tuesday, April 12, 2011

OpenCV in Python, in PHP, in Flash and everywhere else...

A good while ago we were doing a website for one of our social aware clients and the visitors could upload pictures of them and their good friends. But oh my, those pictures needed to be cropped to thumbnails and we couldn't upset the clients by asking them not to upload images in portrait format.
So I looked at my Cake and wondered how could I crop and keep their faces. Ok, that sounds like I have something against our clients and I was about to go Lecter-ish on them which is simply not true. What I mean to say is that I wanted to crop the uploaded images while maintaining the areas containing the graphical representations of their faces in the output.
Now there is a name for that and the name is "Computer Vision". And there is an Open Source project for that and it's name is OpenCV.
And there is a very cool dude who goes buy the name of Robert Eisele who created the PHP Facedetect Extension so all PHP devs can find faces in images. Indeed the extension worked very nice for that project and all the faces were there. I must say that I was amazed by the accuracy. It's mind bogging what computers can do if you tell them how to do it!
But it doesn't come for OpenCV2  and that's what I got on MacPorts.

Good thing I have Python running. Because although OpenCV is C it has a full Python interface!
So now you understand my recent interest in snake taming ;-)

But the coolest thing of the whole stack is, you guessed, Flash!
More precisely the the way that Eugene Zatepyakin, Flash wiz extraordinaire used the Alchemy Project to achieve Viola-Jones object detection in the Flash Player. And that really works. But do check all the other uber cool tricks Eugene has up his sleeve. All are quite impressive and def worth your time.
Alchemy seems to work ok on my OSX 10.6. I managed to do the install steps and compile the basic sample so now the sky would be the limit :-)