notboring dev blog

flex, flash, javascript, videos, games, iphone


Finding alternatives to Mochi that’s closing the gates

Mochi’s owners Shandra are closing down it’s services. They announced it 14 days before the service is unavailable so everybody is in a hurry to find alternatives.

I checked a few:

FGL Ads: Flash Games License Ads

They were easy to implement but don’t offer much choice. Their ad always display as a game blocking popup and the user will be annoyed for having to wait. An solution that I find acceptable once at the start of the game, but not after it.

They only seem to be interessting for the web area, not for mobiles.

Epic Game Ads (epicgameads.com)

Implementation was easy. If you register don’t wonder if you can’t login right after clicking the confirmation link your email. They will manually unblock you.

Skyrocket (www.skyrocketapp.com/)

I had strong hopes for this provider. There was an open sourced ANE for Air, support for multiple ad works and lots of options. Looking for an implementation detail I found out soon that the company behind it got bought by Apple. Which means it very likely has no future in the multi platform market if you look at previous Apple aquisitions.

And it looks like Apple is already murdering the service:

http://techcrunch.com/2014/03/13/burstly-apple-skyrocket/

CPM star

You need a sponsor and according to many postings I found on them they are not making much money. I’ll maybe check it when I find nothing else.

Adbuddiz

This seems to be a mobile only provider. There’s a working ANE for them. This ad provider was easy to implement, the documentation lacked in some areas but everything was solvable.

No Comments

Displaying line numbers as default setting in Jetbrains PHP Storm

To enable line numbers as default on every file you open, you use the settings dialogue:

File -> Settings -> (IDE Settings) Editor -> Appearance -> [x] Show line numbers

That’s it.

[Please ignore this: www.erfahrungen.com]

No Comments

Automated unit testing for code igniter 2.x/3.x

Here’s a quick way to setup unit testing for CI 2.x/3.x:

Step 1: Add a class for testing into your application/controllers folder:

< ?php
class Frontend_Tests_Controller extends Frontend_Controller{
    function __construct(){
        parent::__construct();
    }
 
    public function index(){
        $this->load->library('unit_test');
 
        $this->unit->run( $this->test_reflection(5), 5, "Testing testing" );
 
        echo $this->unit->report();
    }
 
    protected function test_reflection($value){
        return $value;
    }
}

In this file you can add all your tests and then call them from the index function.

Step 2: Add auto loading code for your new testing class to application/config/config.php:

function __autoload($class){
    if (file_exists(APPPATH."controllers/".strtolower($class).".php")){
        require_once(APPPATH.'controllers/'.strtolower($class).".php");
    }
}

Step 3: Add the route to application/config/routes.php

$route['tests'] = "Frontend_Tests_Controller/index";

Now you can call /tests to run the tests.

No Comments

xampp mailtodisk application problem: no emails are being saved, the tool seems broken.

To “fix” the issue, please check the content of your xampp/apache folder. mailtodisk ingores the path settings and write the logs in to a subfolder of the webserver. That means you gonna find your emails in xampp/apache/mailoutput.

3 Comments

Deleting all files from a folder that reached a certain age (x hours/days/weeks/months/years) using PHP

Here a quick example of how to delete all files of a folder that are olden the x days/minutes/hours/months. This method works under both windows and unix. The custom getCorrectMTime() function was posted on the PHP documentation and takes into account that time measurement under windows and unix is slightly different. Of course I also have a small ignore list where files (eg .htaccess, index.html etc) can be blocked from getting deleted.

/**
     * @param $folder the folder in which the old files are supposed to get purged
     * @param $maximumAge maximum file age in seconds
     * @param $ignoreList array() of filenames that should get ignored
     */
    public function deleteOldFiles($folder, $maximumAge,$ignoreList){
        $dir=scandir($folder);
        foreach($dir as $file){
            $secretFileTime=$this->getCorrectMTime($folder.$file);
            $fileAge=time()-$secretFileTime;
            if(($file!='..')&&($file!='.')&&($file!='index.html')&&(!in_array($file,$ignoreList))){
                if($fileAge>$maximumAge){
                    unlink($folder.'/'.$file);
                    //echo "<br />deleting ".$folder.$file." because it has the age: ".$fileAge;
                }else{
                    //echo "<br />keeping ".$folder.$file." because it has the age: ".$fileAge;
                }
            }else{
                //echo "<br />ignored ".$file;
            }
        }
    }
 
public function getCorrectMTime($filePath){
 
        $time = filemtime($filePath);
 
        $isDST = (date('I', $time) == 1);
        $systemDST = (date('I') == 1);
 
        $adjustment = 0;
 
        if($isDST == false && $systemDST == true)
            $adjustment = 3600;
 
        else if($isDST == true && $systemDST == false)
            $adjustment = -3600;
 
        else
            $adjustment = 0;
 
        return ($time + $adjustment);
    }
1 Comment

Fixing the Mochi “Download the latest flash player” bug

I decided to update my Mochi titles to the latest version of the framework: 3.9.5. The compiled files looked nice and worked without flaws. But after uploading them to Mochi, enabling the live updater, things broke.

All I could see was a “Download the latest flash player” message right after the Ad. The game was not accessible anymore.

When checking the Flash export settings in noticed that Flash CS6 seem to have set the plugin version number for the project to the latest version istead of the previous version 9.

Badly enough switching back to version 9 didn’t help, but after a few tries I found out that version 10.3. works perfectly.

No Comments

Simple to use Windows SMTP test server

If you are developing on a windows server using xampp or a similar webserver package you might run into issues with testing functions that reply on emails. That’s because windows got no built in SMTP server.

But there are simple SMTP servers aiming at developers only. and one of them is the antix smtp server:

Since the official antix smtp server is offline and alternative downloads that I checked contained a trojan, here a list of alternatives:

http://smtp4dev.codeplex.com/
https://github.com/yankee42/developmentSMTP

No Comments

xampp: Making CURL available for direct (php.exe/php cli) execution

Open your xampp folder (eg. c:\xampp) and go into the php subfolder (eg. c:\xampp\php). Open the file “php.ini” in a text editor and enable CURL line by replacing the outcommented line

;extension=php_curl.dll

by

extension=php_curl.dll

This enables the CURL extension for both HTTP and the php command line executable (php.exe/php).

No Comments

How to access wordpress functionality using the command line (CLI)

WordPress does not offer any type of command line (cli) support to autmate tasks without using the HTTP protocol. You can easily add it though.

Full fledged wordpress administration using the command line (cli)

wp-cli, a set of tools to manage wordpress from the CLI. It adds access to some of the word press functionality and can be easily extended to run your own code from the command line.

Find more informations about this usefull word press extension at:

http://wp-cli.org/

Directly calling WordPress PHP functions from the command line (cli)

If you just need to run a php script to add own functionality, you can use the following template to initalize wordpress correctly:

set_time_limit(0);
ini_set( "memory_limit", "64M" );
// set this to the path of your file. In my example the php 
// file is in a subfolder, thus there's a ".." to tell PHP it 
// needs to access the parent directory
require_once(dirname(__FILE__) . '/../wp-load.php');

That’s it. Now you can use wordpres functionality like you would do it in plugins. Here a bigger example:

set_time_limit(0);
ini_set( "memory_limit", "64M" );
// set this to the path of your file. In my example the php 
// file is in a subfolder, thus there's a ".." to tell PHP it 
// needs to access the parent directory
require_once(dirname(__FILE__) . '/../wp-load.php');

// now let's access the wpdb database
global $wpdb;
$q = $wpdb->prepare ("SELECT * FROM nb_cntv_video_files WHERE filename_base=%s",$filenameBase);
$results = $wpdb->get_results ($q);
echo "found " . count ($results) . "\n";
No Comments

GIT: Commit fail with exit code 128 (unable to auto-detect email address)

A typical error happening on windows system. To fix it, open the GIT shell and enter the following two lines:

git config --global user.email "you@domain.com"
git config --global user.name "Your Name"

Source:
http://code.google.com/p/tortoisegit/issues/detail?id=1258

No Comments
Rss Feeds