Latest

Domain issues

Posted on 2010-03-05 12:25:17 EET to.

Finally got my domain issues worked out. For long time the domain was pointing to wrong server and for many weird reasons I couldn't get it to update.

Next I'll start transfering this blog to my own server and to a new and improved platform.
Also hopefully finally get some time to actually update it also...

Mobilephone browser detecting from PHP

Posted on 2009-04-17 10:07:34 EEST to .

While ago friend of me asked for a script to detect if site is browsed with mobile device.
There are lot of these around on the net and here is my contribution to that list.

Hopefully someone else find this usefull also:

 

public function is_mobile($include_iphone_and_ipod=true)
{
$mobile_browser = 0;
$user_agent = $this->get_value('_SERVER', 'HTTP_USER_AGENT');

if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($user_agent))) {
$mobile_browser++;
}

if (! $include_iphone_and_ipod) {
if (preg_match('/(iphone|ipod)/i', strtolower($user_agent))) {
$mobile_browser--;
}
}

if ( (strpos(strtolower($this->get_value('_SERVER', 'HTTP_ACCEPT')),'application/vnd.wap.xhtml+xml')>0)
|| (( $this->has_value('_SERVER', 'HTTP_X_WAP_PROFILE')
|| $this->has_value('_SERVER', 'HTTP_PROFILE'))))
{
$mobile_browser++;
}

$mobile_ua = strtolower(substr($user_agent, 0, 4));
$mobile_agents = array(
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda','xda-'
);

if (in_array($mobile_ua, $mobile_agents)) {
$mobile_browser++;
}
if ( $this->has_value('_SERVER', 'ALL_HTTP')
&& strpos(strtolower($this->get_value('_SERVER', 'ALL_HTTP')), 'OperaMini') > 0)
{
$mobile_browser++;
}

if (strpos(strtolower($user_agent), 'windows') > 0) {
$mobile_browser = 0;
}

if ($mobile_browser > 0) {
return true;
}

return false;
}

USB finger, more details

Posted on 2009-03-10 21:44:53 EET to.

As many of you might have already heard from me or various places on the net after my motorcycle accident last year
I got myself a prosthetic USB finger .

After last night when my friend Bergie blogged about this many have contacted me through email and asking if it is true or how can I work while my finger is in the USB or Is it attached straight to my bone, etc.
So I think it is best I'll try to explain some of these here now.

First of all it is not attached permanently in to my body, it is removable prosthetic which has USB memorystick inside it.

 


Secondly when I'm using the USB, I just leave my finger inside the slot and pick it up after I'm ready.

Currently I have Billix , CouchDBX and Ajatus installed inside it.
I'm planning to use the other prosthetic as a shell for the next version, which will have removable fingertip and RFID tag.

I hope this helps some people to better understand what this all is about. 

More pictures on my Flickr photo set.

Crash and burn

Posted on 2008-09-02 15:36:28 EEST to .

Last friday I collided to quite frustrating moment while doing user import to clients Midgard site.

I created a simple import script to parse the old data from CSV and insert them as Midgard persons. After the script runned for a while I started seeing errors that the MySQL wasn't responding. Checked the server and realized that all disks were mounted as read-only and I couldn't mount them back. So after weekend of strugling with the server we decided with the hosting company to move all the data to new server.

After this I made some minor modifications to the import script so it sleeps 2 minutes after every 250 imported users. And monitored the server all the time. After 5hours of importing everything was ready and the server is still doing ok.

So just a small advice to anyone who has to do big imports (over 18k objects), add some sleep time to the import script so the server can take a deep breath once in a while.

on the next Midgard dev meeting I'll try to do this again on a development server and trace for memory leaks.

Midgard Textmate bundle

Posted on 2008-08-07 21:01:38 EEST to .

For quite a while Joonas and I have planned to do a Textmate bundle for Midgard CMS to fasten and ease the code development and work as a reference to the thousands of methods MidCOM and Midgard has.

Finally last night we just decided to put the project on properly and uploaded it to GitHub.
Today I added (and adding right now) quite alot of the basic methods.

Here's a screenshot of shortcuts for the Query Builder.

with these methods even complex queries can be built lightning fast. We will be adding more stuff as time goes by.

PHP5 xmlObject

Posted on 2008-08-05 18:37:23 EEST to .

UPDATE [08/06/2008]: Version update. Did some fixing and made it work better with larger structures.

Here's another simple little helper I developed for Duct framework.
I use this one to convert my arrays to XML. As Duct automatically scaffolds objects from XML/YAML to database
and uses the same methods to render the database objects to html forms for editing I needed some quick way to
transform this data to and from XML. Class end examples are here

Usage example:

<?php
$resource = new xmlObjectItem();
$resource->items = array(
'id' => 100,
'name' => "Jerry Jalava",
'person_id' => 1
);
$resource->attributes = array(
'person_id' => array(
'is_assoc' => true,
'foreign_model' => 'person',
'foreign_key' => 'id'
)
);

$resource_set = new xmlObjectSet();
$resource_set->wrapper_id = 'resource';
$resource_set->items[] = $resource;

$projects = array();
for ($i=1; $i <= 1; $i++)
{
$object = new xmlObjectItem();
$object->items = array(
'id' => $i,
'name' => "Project {$i}",
'manager_id' => $i+1,
'resources' => $resource_set
);

$projects[] = $object;
}

$project_set = new xmlObjectSet();
$project_set->wrapper_id = 'project';
$project_set->items = $projects;

$clients = array();
for ($i=1; $i <= 1; $i++)
{
$client = new xmlObjectItem();
$client->items = array(
'id' => $i,
'name' => "Client {$i}",
'contact_id' => $i+1,
'team-leader' => null,
'projects' => $project_set
);
$client->attributes = array(
'contact_id' => array(
'is_assoc' => true,
'foreign_model' => 'person',
'foreign_key' => 'id'
)
);

$clients[] = $client;
}
$client_set = new xmlObjectSet();
$client_set->wrapper_id = 'client';
$client_set->items = $clients;

echo "complex set:\n";
var_dump($client_set);

echo "\n--------toXml---------\n";

$xmlSet_clients = xmlObjects::toXml($client_set, 'clients');
echo "complex:\n";
echo $xmlSet_clients;

echo "\n--------fromXml---------\n";

$client_set = xmlObjects::fromXml($xmlSet_clients);
echo "client_set root: {$client_set->root}\n";
var_dump($client_set);

echo "\n--------back toXml---------\n";

$xmlSet_clients2 = xmlObjects::toXml($client_set);
echo "complex:\n";
echo $xmlSet_clients2;

if ($xmlSet_clients == $xmlSet_clients2) {
echo "\n\nVALID SET CONVERSION\n\n";
}

?>

PHP5 events class

Posted on 2008-08-04 12:42:01 EEST to .

While I was building Duct Frameworks server side with PHP5 I realized I needed some kind of event support for it.
So I created similar approach that ActionScript uses. You can download the class with example from here.

Hopefully this comes in handy for someone else also. 

Here is simple example also:

 

<?php

class mother extends events_observable
{
public function __construct()
{
parent::__construct();

$this->addEventListener(events_event::ONCONSTRUCT, events::delegate($this, 'on_object_constructed'));
}

public function on_object_constructed($target, $args)
{
echo "{$target->name} has born.";
}
}

class child extends events_observable
{
public $name;

public function __construct($name)
{
parent::__construct();

$this->name = $name;

$this->dispatchEvent(new events_event(events_event::ONCONSTRUCT, $this));
}
}

$mother = new mother();
$child = new child('Jack');

?>

Just added first version of mobile css

Posted on 2008-07-28 13:56:03 EEST to .

If one is to browse this website through phone browser they should see this page fitted on the phone screen.
This is currently tested on Nokia S60 series phones only. Widescreens doesn't show it right yet, but that will be done also after I get test machine for them.

Sudden urge to redesign this layout

Posted on 2008-07-17 23:27:33 EEST to.

I've planned doing this for soooo long and finally I took up the challenge and redid everything...
Later on I'm going to move to other server so I'm getting more recent Midgard beneath and some new stuff to the site.

Hope you guys like this... If you have any comments/wishes drop me an email or shout at Jaiku...

Later

Duct Framework

Posted on 2008-07-17 18:15:30 EEST to .

Duct is something I have planned doing for a while and started coding last week.

What is Duct? (or what it will be)

Duct is a Flash framework with different generators and tools.
with single click it can generate dynamic Flash Sites, Banners, Polls, Surveys, etc. (through engines)
It has it's own server implementation also which allows dynamic content, mail and other features
for Flash. Server side is written with PHP but I have planned a Python version of it also.

Currently Duct UI is built to Flash IDE but I have plans to add Commandline, Online and Standalone support also.

I'm going to publish this as a Open Source project as soon as it gets a bit more mature.
Also more about the whole project will be published later.

Here are some screenshots of the Banner Engine. (And scaffolded banner project.)

scaffoldedBanner.png
(All these files have been generated after pressing the "Create" -button)