Plurk: Instant conversations using Comet
Posted on 30. Jan
· Comments [9]
![]() The web is becoming more and more realtime and we at Plurk are following the trend. Yesterday we released instant notifications so users can have conversations with sub-second delays - - it's like group based instant messaging. Implementing this has not been easy given the complexities and size of Plurk, some problems include:
A demo can be seen here - if that's too boring sign up, invite some friends and try it out live:
Our implementation uses node.js and a big kudos goes to them for their wonderful work. We have rewritten to node.js from Java+JBoss Netty, because the old solution had scalability problems. We have also been able to build a very sophisticated messaging system given JavaScript expressiveness and the simplicity of node.js. Generally, we have found node.js and V8 very impressive - and it uses about 10 times less memory than Java+Netty did. The bottom line is if you implement anything comet related - - try to use node.js! We may release our comet implementation in the future, but currently it's very tied up to Plurk's architecture. I have already shared a lot of my knowledge on comet - including code and a talk about node.js for Taipei Open Source Group. Check out these posts for more info: Comet (long polling) for all browsers using ScriptCommunicator
Posted on 28. Jan
· Comments [6]
![]() There's little information on the web how to implement comet (long polling) so it works across domains and works in all major browsers. I am sharing my solution that's used to power comet on Plurk and I hope this can save time for anyone that has to implement something similar. I have pushed ScriptCommunicator on github and this script can do following stuff:
ScriptCommunicator can also be used to do JSONP calls in a manner where you can handle errors properly. ScriptCommunicator is copyrighted by Plurk Inc. and released under the BSD license. The problemThere are different problems associated with long polling:
To solve this we use script tags for communication and this has one big pitfall: you can't easily find out whatever a script is sourced properly - - so error handling using script tags becomes a lot more difficult. ScriptCommunicator adresses these issues and makes communication easy. The hackIt's trivial to source scripts across domains (you simply append the SCRIPT tag to the head or the body). What's not trivial is finding out if the script was sourced properly and handling errors - and I haven't found a solution for this problem on the net. But there is a solution and it works like this:
It's hacky, but it works :-) How to use itYou source JavaScript from another domain and this domain does a callback to foocall function. You also supply two functions on_success and on_error. var url = 'http://some_domain.com/give_me_js_back.php?i=42&callback=foocall'
ScriptCommunicator.sourceJavascript(url, on_success, on_error)
Either your external JavaScript or foocall sets following attribute to true (to signal that the loading of the script was succefull): ScriptCommunicator.callback_called = true;
That's basically it! Visit ScriptCommunicator on github to get the code. If you are interested in comet check out following amix.dk posts: Nikola Tesla - The Forgotten Wizard
Posted on 23. Jan
· Comments [1]
![]() Once in a while a genius is born that changes the world. Unfortunately this has occurred only a few times in the human history. Nikola Tesla was such a genius and he never got the recognition he deserves - mainly because of his rivalry with Thomas Edison. Nikola Tesla's inventions include AC electricity, neon lights, radio transmission, the electric motor, wireless electricity transfer, remote control, hydraulics and many more things. He had around 300 patents and some of his most remarkable work, such as wireless electricity transfer, never got finished and even today we don't have a full understanding what he was up to. Personally, I am inspired by such a remarkable man and I think his thinking is very interesting, at least from the quotes I have found on him. Here are some of them: Think before you do
What we do echoes in eternity
Don't dwell too much on theory
I recommend checking out this video on Nikola Tesla and his weird and remarkable life (which like this post is named Nikola Tesla - The Forgotten Wizard):
Fixed Mindset vs. Growth Mindset
Posted on 19. Jan
· Comments [6]
The ultimate Vim configuration (vimrc)
Posted on 16. Jan
· Comments [12]
![]() When searching for vimrc on Google you'll find my vimrc from 2006 in the top 10 results. Unfortunately this vimrc is outdated and it included a lot of garbage. I am now releasing a new vimrc that I think is the ultimate and that you can use or get inspired by! My new vimrc can be found here:
If you wish, you can also install my Vim configuration easily (along with some very useful plugins). To install it simply do following: $ mkdir ~/.vim_runtime $ svn co svn://orangoo.com/vim ~/.vim_runtime $ cat ~/.vim_runtime/install.sh $ sh ~/.vim_runtime/install.sh <system> <sytem> can be `mac`, `linux` or `windows` My Vim configuration includes following plugins:
Happy hacking ;-) The colorscheme I use is called peaksea and looks like this:
Applying game mechanics to functional software
Posted on 3. Jan
· Comments [3]
One of the things I find interesting is behavioral psychology and recently I stumbled on a presentation by Amy Jo Kim on how to introduce game mechanics into any product. The first part is rather interesting and she shows how game mechanics work in YouTube and eBay.
Comet with node.js and V8
Posted on 29. Dec 2009
· Comments [0]
A presentation on how to build realtime web applications using node.js, V8 and WebSockets.
This is a presentation I have given to Taipei Open Source Software User Group. A big thanks goes to Ping for the invitation.
Microsoft China rips off Plurk
Posted on 14. Dec 2009
· Comments [7]
Imitation may be the sincerest form of flattery, but blatant theft of code, design, and UI elements is just not cool, especially when the infringing party is the biggest software company in the world. Yes, we’re talking about Microsoft. Interested? Read more:
I am the lead dev & co-founder of Plurk. Please help this spread and help us fight this.
Update 1:
Update 2: A big thanks goes to everyone that has supported us in this. Picasso's bull and Google's fade in page
Posted on 7. Dec 2009
· Comments [3]
Focusing on the essentials is hard, because it's unclear what the essentials are.
Pablo Picasso reduced a bull to 12 pen strokes:
Google still tries to stick to essentials with the new fade in homepage:
Labels:
Design
We are humans
Posted on 29. Nov 2009
· Comments [6]
![]() I walked the streets of Taipei, reflecting on the differences between my culture and the Taiwanese culture - - and suddenly a revelation hit me. The Taiwanese people speak another language than me, they eat different food than me, they ... different than me. But let's look at it from another perspective: The Taiwanese people smile like me, they are as intelligent as me, they love their family like me... And this is the revelation... Focusing on the differences is wrong, we should focus and embrace our similarities. Deep down we aren't Taiwanese, Bosnian, American, Muslims or Jews... We are humans and we have more things in common than in difference! Let's accept our small differences and embrace our many similarities. More love, less hate. Why we are happy?
Posted on 2. Nov 2009
· Comments [3]
This is a great, and somewhat scientific, TED presentation on happiness:
The presentation features also a great quote from The Theory of the Moral Sentiments (by Adam Smith, the father of modern capitalism) :
Labels:
Life
The structure of code is also important
Posted on 1. Nov 2009
· Comments [4]
A thing we forget to think or talk about is the structure that code lives in and interacts with. Building a logical directory and name structure for modules, for templates, for static files is as important as well written code.
Recently, I have done a rewrite of the template structure for Todoist - - where improving the structure played a bigger part of the rewrite. I think this picture speaks for itself:
Thoughts on freedom
Posted on 31. Oct 2009
· Comments [10]
![]() For some years I have thought about freedom and how to achieve it. It hasn't been that easy to specify what kind of freedom I really meant or really wanted. I have tried to specify freedom and how to achieve it and I hope this description can be useful for others that are looking to become free. I have been inspired by Buddhism, but I would not call myself a buddhist. No attachmentsBecoming free implies that you loose attachments. Non-attachment does not mean that you should become indifferent or emotionally cold. It means that you should accept that you can lose your job, your best friend could die and your girlfriend could leave you. Don't fear loss, but accept it as a part of life and something that could and will eventually happen.
Live in the presentLive, embrace and accept the present moment, instead of waiting anxiously for all future desires to be fulfilled. Like Gandhi said: Live as if you were to die tomorrow. Learn as if you were to live forever.
No goals and dreamsGoals and dreams are mostly fantasizes. You build a fantasy of how it's going to be when you get that job or find the perfect mate. When you reach your goal you find out that it was just a fantasy and the taste is not that sweet as you imagined. The lesson is to live in the present moment and not dwell on the prospects of the future. Enjoy what you have now, instead of being a slave of what you want to achieve or become. David Bowie wrote about this delusion in Changes:
Don't actActing like you live in the present moment is not the same as living in the present moment. Acting like you you are non-attached is not the same as being non-attached! Acting is a delusion and if you are acting you are cheating yourself. Don't act free, but be free! It's a practiceBecoming free takes a lot practice. It's not something that you can read your way through or something that magically happens to you. It's a change within and a change that takes a lot of practice. Labels:
Life
Social programming should be a feature of a language
Posted on 28. Oct 2009
· Comments [7]
![]() In this blog post I will argue that future programming languages should focus on the social aspects of programming and be more democratic (especially when it comes to the standard library). History and trendsIn 1995 Perl launched CPAN, which is a Perl repository that holds thousands of Perl modules and their documentation. CPAN is a great success and one of Perl's greatest strengths. It even holds some "social" aspects such as rating modules. Python and Ruby have tried to copy CPAN, but their attempts are not that social in nature and not that good overall, but they do enable developers to quickly push out their packages and for developers to quickly install packages.
In the recent times we have seen the rise of GitHub, BitBucket, Google Code and lots of other projects that make programming more social and that enable easier collaboration between developers. The bottom line is that programming is getting more social, it's relatively easy to push out packages and Perl, Ruby and Python have great success with their packaging platforms. Lacks of the current platformsI'll take Python as an example of the current problems. Python lacks can be applied to other languages as well. In my example I want to find a template library for Python. I search for "template" on Python Package Index: The results as you can see are mostly useless. Mako, which is one of the great template systems, has a score of 1. Jinja, another great template system, a score of 3. Other unknown template libraries and tools a score of 5+. Useless! But that's really the beginning. PyPi is pretty horrific for any kind of collaboration. If I fetch a package I don't have a clear path on how to send back my patches, patches that could be useful for other developers. I don't have a clear path on how to report bugs, bugs which other developers might be experiencing. I don't have an overview of what current patches there exists or what bugs are currently present or have been fixed. The general presentation of the system is pretty bad as well. Why not keep a track of which developers maintain which packages? Or have a reputation system? So if Joe is really active and really helpful, then the system should figure out that Joe should have a high reputation - others can then judge projects based on the reputation of the project and its developers. A reputation system would also introduce a competitive aspect, which could fuel innovation and improve quality. The social platformThe idea of the social platform is to create a platform where developers can collaborate and a platform that promotes quality software. CPAN, Ruby Gems and Python Package Index are early versions of this vision and they need to become more social to become more useful. The social platform should be applied to the core libraries as well and not just be used for the external libraries. A language's standard library should be a democracy where the best and most used libraries win - and not like now, where libraries win by being selected by a few dictators! Essentials of this platform are:
Most of these pieces are partially implemented, especially in products like GitHub and BitBucket. What is needed is a much better integration with the languages. The bottom line is that languages should embrace "social programming" and implement a platform similar to GitHub/BitBucket that enables developers for easy collaboration. The feel good start
Posted on 15. Oct 2009
· Comments [5]
I have lately started to use a hack that can enable me to enter the productivity zone much quicker.
By my experience one of the worst ways to start is by checking or answering emails - - or even worse, start the day by checking news to see what's up. In the past, I have spent tons of hours on kickstarting myself. This little hack addresses the issue of starting off in a good and productive way. The productivity hack I use is quite simple:
Next time you start working, start with this easy task. Hopefully you'll be amazed by the results :-) |
Blog labels |