Общо показвания

май 31, 2011

JavaScript mixins

Oh and while chilling at the beach is great fun, boosts your vitamin D production and so on, it also stimulates you to think more. Not completely related, take a look at the Angus'es post about JavaScript mixins. Very well written and well comprehensible. Good post for any JavaScript developer.

By the way, being a JavaScript developer, do you happen to dream about the day when you would not have to worry about the 'Internet Explorer perks'? Because I do. Dream on, dream on...

Why you should work in Varna

For one - just because you can spend your lunch break at the beach!
Lunch break at the beach!
There probably exists better ways to spend the lunch break, but I don't know about those. If you do, let me know!

май 25, 2011

Pictures

Some pictures I have collected on my phone that have not been seen until now. My stills are not very good (the camera while 8Mpix is not that great on Xperia X10i).

Kaylaka:
I was in Pleven for the previous four days off ( the ones that are related to Easter celebration, for my great luck I am not religious so I just take the days off and go somewhere instead of spending the time in preparation for Christianity's insanity ).
On Sunday we went for a long hike  in Kaylaka, very beautiful place. I really like Varna, but their park ( near Pleven ) is much better than the Sea garden in Varna. However if you come from the shore lines be warned, the air is very very dry in the country, I have had big issue with my respiratory system. even with that it was a great experience.

Small green area near Mall Varna:
This was a few weeks ago, if you look at the right direction and you are deaf you can almost imagine you are in a nice place to live. Anyways just a few meters on the right there is a lot of traffic.

Seaside Observatory:
Last week I moved to my new place, some 400 meters from the sea garden in Varna. A walk in it is always pleasant at all time of the day or night. Still I would suggest you to start around the 'golden' hour and continue from there on until the sunset is complete. It is adorable.

Last one: the beach at 8AM this morning:
South beach at 8AM
It is still May, so there were almost no people on the beach at 8AM (of course there were some, there always are some, even in the winter), but the bars and bbqs around the beach are still closed so it is quiet and calm and you can just lay down on the sand, close your eyes and listen to the birds. I have not notices before but some birds are singing very complex melodies, I was surprised nicely by it. It will remind you of some classical compositions, which is not wonder, many classical melodies have been inspired by the nature. Note that at this time (today) it is still a bit cold on the beach at 8 AM, so you might want to stay with your clothes on. Or not, depending on how well you tolerate the cold wind. I took my clothes off but I felt cold almost all the time, up until I left around 9:20

Here is also a short video, this is a garden people living in a densely populated area made for themselves to enjoy the wonders of nature in the spring, it is really beautiful. An old woman approached me while I was making the video and said:

It is very beautiful, make a video and put it on the Internet.

So this is what I am doing. You can glance her in the video, for only a bit of a second.

май 18, 2011

The evolution of Javascript

During the weekend I ended up cleaning up a mess at my parents' house and I dug in a pile of old books. One of those books was 'Programming with JavaScript' I have bought in 2001. Out of curiosity I sat for a little while and turned the pages to see what was the level of language description in such a book circa 2001.

The author is left unnamed (actually the authorship is signed as 'collective work by SoftPress team).

The rudimentary level of the language description is not surprising, nor the fact that constructor function methods as defined as global functions and then assigned to the object (which is at least a bad practice). What surprises me is the development suggested for javascript. Pretty much all of the examples lead to one exclusive usage for the language and it is form validation. Even today, ten years later no one relies on javascript for form validation just because anyone can skip it, even 10 years old. Why then it was so accented in this small book and why it was suggested that this is the only practical usage of the language?

I can only guess that the engines in IE5/Netscape3/4 were so slow it really was the only practical usage of the language.

Today it took me only 5 minutes to convert a slider application from jQuery to Mootools. Complete with animation and all. It is working in Firefox 3, 3.5, 3.6, 4, Chrome 7-12, Internet Explorer 7,8 and 9. I wonder, how much time will it take to write the same thing, working across browsers, 10 years ago?

I also remembered that I saw my first javascript driven animation in the browser around that time, it was working only in IE and it was timeout driven style altering algorithm (basically the same thing we do today) and it was written very expressively with one main function in global scope and several function inside the main function scope, it was using closures and it was using native type augmentation, which I think was very advances for that age.

Anyways, don't buy this book, it is worthless these days. One advantage it has over the modern books is that is explains in details the CGI metaphor very clearly and provides details on the internal working of a program using this interface, something you can learn today but not in a javascript book!

Talking of books I took a brief (but complete) look at Pro JavaScript with MooTools. Unfortunately there is nothing 'Pro' in the book itself. It starts with too in depth introduction of the types in javascript, somewhat deep look at the functions and objects and then complex code is thrown at the reader without even explaining it all, just 'the interesting and important' parts of it, which I find rude and unprofessional, a code example should ALWAYS be explained in details and the whole of it, otherwise it is waste of book space to use examples if just a single row in it will be important and explained. Other than that the book only covers the class system and briefly mentions the different mixin types in mootools, something you can read and understand from the docs and it takes only 5 rows, not a whole chapter. After that it gets boring until the end of the book, Element, Style and other parts of the toolkit are depicted in unnecessary details, details that one can easily fond in the documentation. Also there is nothing advanced in the book itself and I don;t see how any advanced technique can be learned from it, providing there is not a single example demonstrating such technique. All in all the book is not worth reading if you do not know javascript, it is not meant to be a learning tool for javascript. However if you know javascript and can read English you should not read it either as it does not provide any new information regarding neither javascript nor mootools. Actually the only interesting part in the whole book is the mention and explanation of the 'parent' property of the extended 'classes'. However this can be read on so many places online, so the book is rendered completely useless. Oh and by the way the last chapter is also completely insane, birds eyes look at the server side javascript programing without any real life examples nor advices. Really annoying.

So, how did the language evolved? Well, the language did not, the browser evolved. And today it is a really great tool as well as really really great development platform, I encourage you to learn javascript and use a solid framework ( regardless of what you read online (that the micro frameworks are the future) they are not - most of those (like 90%) are not working correctly across browsers, the top class libraries are tested and do work! ) like jQuery or MooTools (I am not sure which to recommend because I do not speak jquery, I only speak pure JavaScript and MooTools) and just explore the possibilities of a modern browser. Yes, it is true that your application might not work in IE or Opera or some old Safari browser. But hey! I wrote a music player in 20 minutes in chrome!! So can you! And endless other applications! And it is really easy! For fun and for profit, javascript is your friend and is here to stay! So take the time and learn a bit about it.

май 10, 2011

Нотово 'риалити шоу'


Така. Новото риалити шоу се нарича 'Фермер търси жена'.
Коментар на жената*:
-Значи така, а? Аз ще ходя да му копая, да ора, да сера във външната тоалетна и да се къпя в коритото в кухнята! Няма да стане!

Мисля, че това е един шедьовър на краткия анализ!

PS: *ролята на жената е изиграна от моята майка, Дочка.

май 08, 2011

Coud9 beautify

Just a small demo of the dev branch beautifier in cloud9. By the way it does not preserve the indentation as you can see in the video but I do not think it is a big problem. I think it is awesome.

cloud9 local and alsa equalizer

I am very pleased with recent cloud9 service (very nice thing is integration with github and the fact it is running fast enough with my new browser of choice (Chrome)). However it is kind of impossible for me to host all my projects on github and constantly sync the files to local file system just to test the code on local embedded device (the device mounts the files over NFS, there is no way I would make a change on Cloud9 service, git push to github, git pull to local copy for every simple change in the code I made, it is just too much work). I needed a way to run the editor somewhere on the local network.

For a while now it does not play well with node 0.4. Today I asked Google if there is a way around that. It happened so that there is a very simple way. You can follow the instructions from here (I have tested it and it all worked well).

I have also added some features to the music player in the browser, but I have more ideas (I hope it will not ravels into full fledged enormous memory hog it can easily become if I get carried away).

I had a problem with the music playback though, I dislike basses so I wanted to lower them. Maybe there is a way to do this in JavaScript with the audio API, but it sounds like too much work. Instead I wanted to regulate the playback tone volumes globally, so I used AlsaEqual. The installation is very simple and works well, just follow the instructions. I used the global setting because I hate basses on everything, including movies and I was not sure if Chrome can play back sound on selected card. You can adjust the tones in the console: alsamixer -D equal will do the trick.

Oh and by the way on cloud9 development there is a great feature - JS beautify! It works great, helps with very complex code (like the one I use to write when creating complex html with Element in mootools) and is configurable. Try it out!

май 07, 2011

How to write yourself a music player in 20 minutes

I am working as JavaScript developer.
I spend most of my work day in the browser (now days 'the browser' being Chrome).
I read my emails.
I read my news.
I talk to my colleagues, friends and family.
I do research.
I code.
I entertain myself.
All in the browser.

However I like to listen to music sometimes. I have a big collection of my favorite music collected over the past 12 years, however to be able to filter it and listen to it I need a separate program, a 'music player'. I asked myself: 'Why should I use an application I cannot modify. Isn't it in the spirit of OpenSource to be able to use something you can read, change and use however you like?'.

I do use open source music player, however it is written in C++ and GTK, language and library I do not understand very well. It does not decode the stream, and I am not really interested in that part. Chrome can decode audio in at least mp3 and ogg formats, so why not use the browser to play back my files. But then again I should be able to display my collection and filter it. How hard could that be to do in the browser.

Not hard at all. Enter OmniGrid. It is able to display your data in a table, sort it and filter it, all it require is that your data is loaded as JSON valid object. My regular music player is Rhythmbox, so I can download the xml file, convert the data with DOM however I like it and load it in the grid view, then filter it. It is very simple and straight forward. I will also need an audio tag and pause button.

So here it is:



OmniGrid requires mootools and mootools-more (of course not the whole of them, you can custom build for it), but it makes the application code very very small! Mine is 117 rows only and most o it is to create the tags and bind events to it because I do not like writing html files, I like creating them with JS on domready.

I encourage you try and write whatever you use on your desktop that is not available yet as web application and share it, so we can finally move on from the desktop paradigm and be able to live online and on whatever laptop/computer we are currently having.

I for example feel pretty awful when my laptop breaks or need to be taken for cleaning, this whole thing can be painless if my digital life was stored on a server and accessible from a web interface, then all i would need would be a browser. Kind of the idea behind 'Chrome OS'. I like it. I agree that maybe not all our data should be on Google's cloud, but I have my own server. I could just store my things on my server. On an encrypted partition. Yeah... and then I could just use any laptop. Any that is not with key loggers on it though...

UPDATE: The code for this small App is available here. It cannot be used as it is, because it assumes you have your rhythmbox DB file in the same directory and assumes the directly structure and your system user name, however it is pretty easy to modify. Enjoy.

май 01, 2011

This is the time we live in


First
I'd like to mention the inspirations for this post, number one being of course late Carl Sagan, the first face of the science I have met when I was very young, barely understanding English (my first language being Bulgarian). I was then hooked by this, in my opinion, most profound and wide introduction to the scientific world, the most interesting and important for a kid enlisting of all the achievements made for such a short period of time, considering the thousands of years we have been around. It was then when I knew I want to be part of this scientific advancement, I wanted to see us, human race, wandering trough the stars, exploring, looking for anything that awaits up there in the vastness of space and time. It was Sagan, who lighted up my mind and calibrated my point of view for this world, wonderful an magical even without the superstition and spirituality and 'real' magic that floats aroun
d us, obscuring so many real and great ways we can admire and contribute to the miracles of science!

I like to thank also Jill Tarter, the passionate researcher, who has devoted her career to SETI. I was amazed and inspired by her TED talk few years back and I truly believe it takes courage and passion in science to constrain your life to such a wonderful idea as to find the proof that we are not alone in this enormous universe. I hope the institute will get back on its feet, I hope there are still people who are willing to help considering the immense importance of the work those dedicated scientist are doing, regardless of the fact that more and more pressure is building up against spending money on such research, I still believe that even more money is wasted on stupid things, much more money, which used otherwise would have improved our lives beyond anything imaginable. Yet those people having those resource are not willing to help, so I urge anyone who can help to do it now, because as Carl said it - we need to take a look in the future, we need to embrace our unimportance and have the tiniest vision of tomorrow.

I also would like to thank the people behind the wonderful adaptation of Sagan's Contact for the wide screen, which inspired me to give a second thought on mathematics and physics, two disciplines I was not very interested in when I was in high school and in the university, I was barely understanding it, as much as to pass my exams. Now I understand the beauty and importance of those and without blaming it to the teachers and assistants trying to inspire us I now recognize it was a big mistake to just presenting the scientific knowledge without first trying to present its role and importance and beauty and application to the young minds. I am certainly hoping this will change soon and will produce a new generation of passionate scientists. Meanwhile I hope we will see more positive scientists as main characters in movies.

Next are all people that are tributing Carl Sagan all over the Internet, especially the wonderful clips from the young fellow over Milky Way Musings made me such a great impression. If you have the time and you like Sagan, please go and watch the clips.

I also want to thank the people behind the chrome and firefox projects for making the web experience such a joy as to allow me and countless other people to use the World wide web as easily and enjoyable as possible, which on the other hand inspired us to contribute in any way possible. It would have been a terrible experience without your work and I would have not discovered so much without it, so thank you guys and gals for your hard work!