Archive for open source

Vigilante and Vigilante Mobile, the beginning

Just did the initial project importing for Vigilante and Vigilante Mobile, for now only a couple of hackish multipart jpeg viewer to use with Motion.
Vigilante is supposed to be the main “full-featured” application, it is written in C++ and C using gtkmm and gstreamer, but it’s my intention to make it modular so new backends other than gstreamer could be added.
Vigilante Mobile is a small multipart jpeg viewer meant to be used on every Java (J2ME) enabled mobile device.
I choosed the GPLv3 license but I need to do some more research on it, I’m not really sure.

Comments

Reinventing the square wheel

Square root bike crying kid
This morning I was browsing Planet OpenSolaris when my attention was caught by a post talking about some really strange new language: it introduces the Vala language, a new high level language that «aims to bring modern programming language features to GNOME developers without imposing any additional runtime requirements and without using a different ABI compared to applications and libraries written in C».
So, let me resume what’s happening here: «hey, C is cool, a lot of people know it, we like it, we should definitely choose it as a base for our framework/DE, it doesn’t matter if C isn’t object oriented and we want to write object oriented code, we will find a way to put objects in C, maybe writing some framework and anyway g++ now just suck so C++ is not an option at all»
then after some years «hey, look at those Python/Perl/Ruby/C#/Java guys’ attitude, they are not happy if they don’t create some kind of weird wrapper to our marvellous code, what’s their problem? They can’t get a better API than the original API, let’s be serious, the original API is wrote in/for C and C is so cooool, they are wasting their time. Anyway, let’s take a look on their code… Uhm… well… actually… it isn’t so bad, there is no way that it could be better than the C api of course, but well, they had a couple of good points… ok maybe three or four good points… Maybe we should backport something to the core but doing that with C isn’t very confortable, we aren’t saying that C isn’t (or wasn’t) the better choice of course, there is no way we could say something so silly (C is so coooool) but we must find a way… g++ got quite good in the meanwhile but hey, C++ is C++, it has so many features, it will confuse our users for sure and it is so old, it can’t be cool-looking/new-fashioned/modern-elegant(/marketing-brain-wash-powered someone says: odd fools, there is no way we could fall for suck stupid tricks, as my iPhone can prove I think different!), we must find another way, maybe… a new language? Yeah, this appears quite reasonable: we are not betraying C at all because our compiler will translate the new language code to C code hiding the pain to write C code from our users! Our users will be able to write C but will not suffer anymore because they will not write C! So coooool!»

Comments

XML importer from Danea Easyfatt to Cubecart

This is ugly, bugged, wrote in PHP (I’m not a PHP programmer) and will probably send death threats emails to all of your customers (really, I didn’t have the time to test it)
If you still want it this is the code:

<?
file_handle = fopen($file, ‘a’);
    }

    public function __destruct()
    {
        fclose($this->file_handle);
    }

    public function write($buffer)
    {
        fwrite($this->file_handle, $buffer.”\n##################################\n”);
    }
}

//Importer implementation for the Cubecart
abstract class Importer
{
    protected $logger;
    protected $dbh;
    protected $xml_products;

    public function __construct($import_str, $host, $dbname, $user, $pass, $op)
    {
        $this->logger = $op;
        $this->dbh = new PDO(’mysql:host=’.$host.’;dbname=’.$dbname, $user, $pass);
        //$xml = simplexml_load_file($xml_file);
        $this->import_data($import_str);
        $this->update_and_delete();
        $this->insert_new();
    }

    public function __destruct()
    {
        //print_r($this->cats);
    }

    protected function query_has_row($sql_query, $str_id = “cat_id”)
    {
        //echo “$sql_query\n”;
        //$s = $this->dbh->query($sql_query);
        //if ($row = $s->fetch())
        foreach ($this->dbh->query($sql_query) as $row)
            return $row[$str_id];
        return false;
    }

    abstract protected function import_data($import_str);
    abstract protected function update_and_delete();
    abstract protected function insert_new();
}

class CubeImporter extends Importer
{
    private $cats = array();

    protected function import_data($import_str)
    {
        $xml = simplexml_load_string($import_str);
        $this->xml_products = $xml->Products->Product;
    }

    protected function update_and_delete()
    {
        foreach ($this->dbh->query(’SELECT * from CubeCart_inventory’) as $row)
        {
            foreach ($this->xml_products as $product)
            {
                if( $row[’productId’] == $product->InternalID )
                {
                    //print($row[’productId’].” update\n”);
                    $this->update_row($product);
                    continue 2;
                }
            }
            //print($row[’productId’].” delete\n”);
            $this->delete_row($row[’productId’]);
        }
    }

    protected function insert_new()
    {
        foreach ($this->xml_products as $product)
        {
            foreach ($this->dbh->query(’SELECT * from CubeCart_inventory’) as $row)
            {
                if( $row[’productId’] == $product->InternalID )
                {
                    continue 2;
                }
            }

            $this->add_row($product);
        }
    }

    private function add_cat($cat_name, $cat_fat_id = “0″)
    {
        $this->dbh->exec(”INSERT INTO CubeCart_category (cat_name, cat_father_id)”
        .”values (’$cat_name’, $cat_fat_id)”);

        //echo “ho inserito “.$this->dbh->lastInsertId().”\n”;
        return $this->dbh->lastInsertId();
    }

    private function check_categories($xml_product) //needs some refactoring
    {
        if (array_key_exists(”Subcategory”, $xml_product))
        {
            $a = array_search($xml_product->Subcategory, $this->cats);
            if ($a == false)
            {
                $a = array_search($xml_product->Category, $this->cats);
                if ($a == false)
                {
                    $a = $this->query_has_row(”SELECT * FROM CubeCart_category WHERE cat_name = ‘$xml_product->Category’”);
                    if ($a == false)
                    {
                        //inserire cat
                        $a = $this->add_cat($xml_product->Category);
                    }
                    //$this->cats[”$xml_product->Category”] = $a;
                }
                //$a deve contenere id di cat
                $fa = $a;
                $a = $this->query_has_row(”SELECT * FROM CubeCart_category”
                .” WHERE cat_name = ‘$xml_product->Subcategory’ AND cat_father_id = $fa”);
                if ($a == false)
                {
                    $a = $this->add_cat($xml_product->Subcategory, $fa);
                }
                //$this->cats[”$xml_product->Subcategory”] = $a;

            }
        } else { //If Subcategory doesn’t exist then there must be at least a Category
            $a = array_search($xml_product->Category, $this->cats);
            if ($a == false)
            {
                $a = $this->query_has_row(”SELECT * FROM CubeCart_category WHERE cat_name = ‘$xml_product->Category’”);
                if ($a == false)
                {
                    $a = $this->add_cat($xml_product->Category);
                }
                //$this->cats[”$xml_product->Category”] = $a;
            }
        }
        return $a;
    }

    private function add_row($xml_product)
    {
        $cat_id = $this->check_categories($xml_product);
        $tax_id = $this->query_has_row(”SELECT id FROM CubeCart_taxes WHERE taxName = “.”‘IVA’”, “id”);
        $s = $this->dbh->prepare(”INSERT INTO CubeCart_inventory (productID, productCode,”
        .”price, name, cat_id, sale_price, stock_level, taxType)”
        .” VALUES (:productID, :productCode, :price, :name, :cat_id, ”
        .”:sale_price, :stock_level, :taxType)”);

        $s->bindParam(’:productID’, $xml_product->InternalID);
        $s->bindParam(’:productCode’, $xml_product->Code);
        $s->bindParam(’:price’, $xml_product->GrossPrice3);
        $s->bindParam(’:name’, $xml_product->Description);
        $s->bindParam(’:cat_id’, $cat_id);
        $s->bindParam(’:sale_price’, $xml_product->GrossPrice3);
        $s->bindParam(’:stock_level’, $xml_product->AvailableQty);
        $s->bindParam(’:taxType’, $tax_id);
        $s->execute();

        $this->dbh->exec(”INSERT INTO CubeCart_cats_idx (cat_id, productId)”
        .” VALUES ($cat_id, $xml_product->InternalID)”);
        $this->dbh->exec(”UPDATE CubeCart_category SET noProducts = noProducts + 1
        .”WHERE cat_id = $cat_id”);
    }

    private function update_row($xml_product)
    {
        $cat_id = $this->check_categories($xml_product);
        $tax_id = $this->query_has_row(”SELECT id FROM CubeCart_taxes WHERE taxName = “.”‘IVA’”, “id”);
        $sql = “UPDATE CubeCart_inventory SET productCode = :productCode, price = :price, name = :name, cat_id = :cat_id, ”
        .”sale_price = :sale_price, stock_level = :stock_level, taxType = :taxType WHERE productID = :productID”;
        $s = $this->dbh->prepare($sql);

        $s->bindParam(’:productID’, $xml_product->InternalID);
        $s->bindParam(’:productCode’, $xml_product->Code);
        $s->bindParam(’:price’, $xml_product->GrossPrice3);
        $s->bindParam(’:name’, $xml_product->Description);
        $s->bindParam(’:cat_id’, $cat_id);
        $s->bindParam(’:sale_price’, $xml_product->GrossPrice3);
        $s->bindParam(’:stock_level’, $xml_product->AvailableQty);
        $s->bindParam(’:taxType’, $tax_id);
        $this->logger->write($sql);
        $s->execute();
    }

    private function delete_row($id)
    {
        //echo(”$xml_product->Description\n”);
        $cat_id = $this->query_has_row(”SELECT cat_id FROM CubeCart_inventory WHERE productId = $id”, “cat_id”);
        $this->dbh->exec(”DELETE FROM CubeCart_inventory WHERE productId = $id”);
        $this->dbh->exec(”UPDATE CubeCart_category SET noProducts = noProducts - 1
        .”WHERE productId = $cat_id”);
    }
}

$op = new Outputter(”/path/to/log/asd.txt”);

if (array_key_exists(”file”, $_FILES)) {
    move_uploaded_file($_FILES[’file’][’tmp_name’], “file.xml”);
    $xmlstr = file_get_contents(”file.xml”);
    $op->write($xmlstr);
    $ci = new CubeImporter($xmlstr, ‘localhost’, ‘database_name’, ‘username’, ‘password’, $op);
}
$op->write(var_export($_FILES, true));
$op->write(var_export($_POST, true));
echo(”OK”);
?>

Danea Easyfatt to Cubecart XML importer version 0.1

Comments

Venezuela to power up Linux development in Sud America

Please excuse me for the big copy & paste from this page, it’s worth it:

Mérida, June 12, 2007 (venezuelanalysis.com)— The Venezuelan government of President Hugo Chavez announced the launch of their “Bolivarian Computers” last week, consisting of four different models produced in Venezuela with Chinese technology. The new computers will run the open-source Linux operating system and will first be used inside the government “missions” and state companies and institutions but eventually are expected to be sold across Venezuela and Latin America.

Venezuela’s President Hugo Chavez presented the new machines to the public last week at an event in the state of Falcon as he donated them to a school there. The new computers are produced by the joint venture VIT (Venezuela de Industria Tecnológica), which is owned by the Chinese company Lang Chao and the Venezuelan Ministry of Light Industry and Commerce.

“The price of other similar brands is US$ 930, and the price of our computer is US$ 690, almost 40% less,” explained President Chavez. “But, in addition, it has an added value, given that it comes with open-source software and a three year guarantee, while other brands only offer one year.”

Production of the models began in the end of 2006 and the first 1,619 units were distributed to students of Integral Medicine in the government program Mission Sucre. Chavez promised last October to give a computer to every one of the 11,100 students in the second year of the new medical education program Integral Community Medicine (MIC) and began to follow through with that promise last May.

“I feel excited because the president came through with his promise, and that makes us be more responsible with the program, more dedicated, since it is a big help that motivates us to keep moving forward,” said one student.

Units have also been given to the Urban Transportation Fund, the Agrarian Bank, the national mail service Ipostel, and the Experimental University of Simon Rodriguez.

And although the first units have been donated to the public sector, the new Bolivarian computers will also be sold inside Venezuela and exported.

“We are working with cooperatives and small companies to form our own distribution network,” said the manager of sales Eduardo Hernandez. “It’s a slow process. This month we have already completed the formation (of a distribution network) in Caracas and by the end of the year we will have distribution and technical support throughout the whole country.”

The computer factory is located on the Paraguana Peninsula in the state of Falcon and has an annual capacity of 150,000 units. For this year the factory is expected to assemble 80,000 units and 6,000 laptop computers.

Until now Venezuela has always imported computers both from well-known brands and generic brands from the developed world. With this new venture the Venezuelan government hopes to diversify national production, integrate national productive chains, and work towards technological independence for the country.

According to the web page of the new state company, VIT has the objective of “production, marketing and sale of technological products, with an emphasis in manufacturing and assembling computers and accessories. Our efforts are also focused on national export, with a future projection to the international market.”

By the end of the year, the intention is to begin to locally produce some of the technology in order to substitute some of the imported components used in the assembly of the machines for components produced in Venezuela. In order to do this, the government has built installations for research and development in order to design the components inside the same factory.

The company is offering 3 different desktop models and one laptop with a price range of US$ 405 (Bs. 870,750) to US$ 1,400 (Bs. 3,010,000). The processors will range in speed from 1.5 GHz to a 3.0 GHz Intel Pentium IV and the laptop will use a 2.0 GHz Intel Core 2 Duo processor.

With respect to the operating system, Venezuela has taken a strong position in favor of open-source software in order to “promote technological development” and help “reach technological independence.” For this reason the computers will use the open-source Linux, but the components are also compatible with the Windows operating system.

By: Chris Carlson - Venezuelanalysis.com

Comments

3D rendering requires money

Take a look on this:

It is a sample rendering from a blender demo scene.
It took about one hour to render it on my 2ghz Core2 Duo with Gentoo x86_64 and Blender 2.44 (64bit).

Comments