Wednesday, December 5, 2012

SpineJS Tip

Never create multiple instances of a controller that generates the same view, cause you're event's registrations will be duplicated over and over again!

Wednesday, September 26, 2012

Avoid usage of AsyncTask Class on android

Just noticed this method available from API 11 only,  so you should find another implementation to avoid unexpected behaviour.

Or don't call the execute method,  why?  If you'll check documentation you'll see that in some versions of android all tasks will run synchronouslly on the same background thread and on some versions it'll run on a pool of threads. Always use the executeOnExecutor option for consistent behaviour between platform version and avoid unexpected behaviour.

See docs

Friday, August 31, 2012

Nice idea for what's new in my app

People probably don't read/understand what's new in an app when they update it.  Skype did a very nice screen that shows you that something did change


Sunday, July 8, 2012

coffee-script is another piece of shit

Hi,

A few months ago I discovered this new stuff called coffee script, and thought to myself, "this is awesome I'll write less and do more" Today, I tried to continue a development of a pretty fat client side and tried to find myself in the 1000 lines of code I wrote so far (not so many). It was pretty hard, and I'm the only programmer for now, can't imagine how a new programmer would enter to this project.

So...
coffee-script is java-script that look better, no other benefits, and if you plan to write a little more than 200 lines of code, consider using some strongly typed language(that can generate debugable java script) with good IDE that'll help you maintain your code. 

Saturday, July 7, 2012

php post response script execution

I guess it's nice to have so here you go


/*
 * basically allow a php script to return a response and continue with
 * code execution, good for statistics.
 * before echo anything to user call begin and after call end, than you can continue doing stuff
 */
class ScriptContinuationManager
{
    /**
     * this is the point where we need to give a sign to this class
     * that we wanna write our response.
     * @return void
     */
    public function beginRespone()
    {
        ob_end_clean();
        header("Connection: close");
        ignore_user_abort(); // optional
        ob_start();

    }

    /*
     * after this function execution the response will be sent to the
     * client, and code continue without client need to wait.
     */
    public function endResponse()
    {
        $size = ob_get_length();
        header("Content-Length: $size");
        ob_end_flush(); // Strange behaviour, will not work
        flush(); // Unless both are called !

    }
}

Tuesday, June 12, 2012

For all you android developers, If you ever installed a new rom and didn't see any logs from your cat, just do this:

http://stackoverflow.com/a/7272831/67505

Wednesday, March 28, 2012

Rails + Mongo + Heroku how?

After a few hours of fighting with google I decided to write it all here:

*This post is more relevant for windows users but can help others.

What do you need to have:
First you need to have ruby 1.9.2+
Devkit
then you need rails 3+
then u need the bundler gem
then go to getting started with mongoid
then install mongo locally
then check it all good
then add acoount in heroku
then create app
then add your key
then push

Saturday, February 18, 2012

CoffeeScript - language review

This weekend I learned a new programming language, called coffee script, It's not a real language it's actually compiled to JavaScript, so it's a way to write JavaScript differently.

After a little hands-on and one book read I can say that this is a good language for experienced and non experienced JavaScript programmers. 

What's awesome about this language is that is fills like someone took all the good stuff from ruby python and java, and put it in one language that eliminates all the crap you need to take form JavaScript programming.

I can start writing all the good stuff about coffee but there is no need just dive into 
http://coffeescript.org/ and you'll understand all the benefits.

Saturday, January 7, 2012

PHP Sessions

One more thing,

If you do stuff like put instances of classes inside a session and expect to call methods of this classes later, you must put the session start after you include the classes definitions.

But I suggest not to do this kind of stuff.

Friday, January 6, 2012

PHP sessions - stuff to check when things goes wrong.

There is too much information about problems with sessions in PHP, every dude got it's own problem and it's own solution.
The probability that the problem you experiencing is the same is very low. 
So here is what my little (and very annoying) google journey came up to:



  • You must call session_start(); on each page
  • If you use the header('Location: blabla'); you should use relative url to keep preserve session 
  • some people say before using the header action you need to call  session_write_close(); - I'm not using it.
  • session_write_close(); could be the reason to your problems, cause after calling it you can't modify the session (in the current http context), that was my problem.
  • on php docs, they say that "Session ID is not passed with Location header even if session.use_trans_sid is enabled. It must by passed manually using SID constant."
So first make sure you use session start, if you passed this search for voodoos like  session_write_close() in the middle of your infrastructure and remove them.

If I didn't help, continue the journey.