Friday, May 17, 2013

XBMC Addon Development - Updated Zip file doesn't update addon issue

Problem:
While working on an XBMC addon, I got my addon to install properly and then decided to make some changes. I Uninstalled the addon and tried to install the new Zip file but the old addon showed back up and none of my changes existed.

Solution:
I'm still not sure why I can't upload a new Zip file with an update, but I found a better way to development the addon anyway. By placing the folder with my addon into the {XBMC Install location}/addons folder, I was able to restart XBMC and have my changes take effect immediately.

I hope at some point I can understand why updating via a Zip file wasn't working, but for now, I'm just going to develop in the addons folder. If you know why it wasn't working, leave a comment below!

Thursday, May 16, 2013

XBMC: ERROR: Unable to create application. Exiting - Fix On Windows 7

Problem:
In my spare time I've been writing a python script addon for XBMC. While developing I was tailing the log file, but trying to restart the application, I got the following error message:

ERROR: Unable to create application. Exiting

Solution:
It turned out that for me, this error was caused by keeping the tail open on the log file when trying to restart the XBMC application. Closing the tail and reopening each time I launched the application made the application launch correctly.

Wednesday, May 15, 2013

Laravel 3: Unlimited routing arguments

Problem:
I was working on a project in Laravel when I realized I really wanted to have 1 route rule for a specific controller but be able to allow a lot of different arguments.

Solution:
I found that I could use func_get_args() in conjunction with the static Controller::call() method to handle an unlimited number of arguments to the receiving controller method.

Route::any('users/(:any?)/(:any?)/(:any?)', array(
        'as' => 'users', 
        function(){
            $args = func_get_args();
            if (empty($args)){
                $action = 'index';
            }else{
                $action = array_shift($args);
            }
            return Controller::call("users@{$action}", $args);
        }
    ));

There is one caveat to this solution, and that is that you have to specify all the possible captures in the Route URL rule although extra captures are ignored.

Thursday, May 2, 2013

Adobe AIR: Getting HTML Source on MX HTML Component

Problem:
I decided to write a tool that would aggregate data from web sites as one surfs the web, kind of like a browser with some extra functionality. It soon became apparent that the <mx:HTML> component didn't have a simple "source" property where I could see all the HTML from the website.

Solution:
It turned out to be a simple task. The HTML component has a property which allows you to access the HTMLLoader object associated with the component. The HTMLLoader object has direct DOM access using Psuedo DOM objects (basically basic objects with a couple preset properties called Nodes and NodeLists). Many of the JavaScript dom functions exist in this representation and will work just fine.

For example:
getElementById
getElementsByClassName
getElementsByTagName

Using the last one along with the innerHTML property, we can get the source of the body element.

html_component.htmlLoader.window.document.getElementsByTagName('body')[0].innerHTML;

I'm sure you could get the entire document source if you wanted to examine the page head, etc. But these weren't useful for me.

Good luck!

Monday, April 15, 2013

Laravel Routes: Missing argument 1 for {closure}()

Problem:
While trying to develop quickly I set up a routing rule for Laravel that I thought was correct. But when I tried to access the page, I was met by this error:

Missing argument 1 for {closure}()

My Routing Rule looked like this:

Route::any('dashboard', array(     
    'before' => 'auth',     
    'as'     => 'base',      
    function($action){         
        return Controller::call("user@index");     
}));


Solution:
This was an oversight on my part, the closure used in the route expected an argument which would be the information obtained by any shortcuts [(:any),(:num),etc.] or regex rules. Since this particular route didn't have any captured portions of the URL, the closure also expected no arguments. My working route looks like this with the argument removed:
Route::any('dashboard', array(
    'before' => 'auth',
    'as'     => 'base', 
    function(){
        return Controller::call("user@index");
    }
));

MySQL: Prepared statement needs to be re-prepared

Problem:
While developing a web site on my development service provided by Dreamhost, I found that I would occasionally (and randomly) run into the following error:

General error: 1615 Prepared statement needs to be re-prepared

I began searching for a solution thinking it might be something with the Laravel framework. Then I found this page about a MySQL bug.

Solution:
Ultimately it appears that the best solution is to force the table cache to renew in mysql (more information about mysql repreperation), but if that is not an option, you can try forcing the table optimization or defragmentation for the table causing the issue.

This is understandably a work-around which is not idea for a production server. In the case of a production server, you can try modifying any of the following database settings:


table_open_cache 128=>16384
table_definition_cache 1024=>16384
tmp_table_size 32M=>64M
join_buffer_size 256k=>512k

If you have any more information on this issue, please post a comment below!

Thursday, April 11, 2013

BitBucket: info/refs not found: did you run git update-server-info on the server?

Problem: 
I set up a new repo on bitbucket.org for a project I've been working on and once it was ready for me to add my code, I kept getting the message:

info/refs not found: did you run git update-server-info on the server?

Solution: 
After destroying and creating my .git folder over and over trying to verify my remote path and that I had done the same steps as I had done many times before, it finally clicked what the problem might be. When I had names the repo on BitBucket.org, I had used a hyphen in the name. I changed the name to have a space instead of a hyphen and changed it enough that BitBucket accepted it as a new name. Then I repeated the steps as before and it worked as expected!

Now there are many reasons why you might get this message but hopefully this gives you a possible solution.

Good luck!