bloginfo('name');

bloginfo('description');

Archives Posts

Resetting the MySQL root password…

Februar 3rd, 2009 by Blu:RayNe

A little snippet you may need from time to time ;)

$ /etc/init.d/mysql stop
$ killall mysqld; sleep 5; killall -9 mysqld
$ sudo /usr/bin/mysqld_safe –skip-grant-tables &
$ mysql
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD(‘myNewPAssword’) WHERE Host=‘localhost’ AND User=‘root’;
mysql> exit;
$ /etc/init.d/mysql stop # (no ‘restart’ here or mysql may reload without grant-tables!)
$ /etc/init.d/mysql start
Filed under Allgemein, Datenbanken having No Comments »

Archives Posts

Uploads via HTTP are still an issue…

Februar 1st, 2009 by Blu:RayNe

Even in the days of Web 2.0 you encounter many errors when it comes to Uploads via HTTP. The protocol was never made for uploads or better to say: there are still enough bugs in implementations and the protocol itself.

Very familar, e.g. is the problem of having a meter on upload progress. And i also don’t want to mention the problems of WebDAV implementation of Windows for now, or the limitations of firewalls or proxies…

But let’s have a look on solutions provided today in the Web for Uploads…

Flash/HTTP

We have a modified version of R6 running on a webshop with regular uploads of 20-70MB files. If upload goes to fast – like on business lines with upstream ≥3Mb – Flash is likely to throw errors telling the visitor a script is running too slow. Then the customer has to choose „continue“ or to „cancel“, which usually ends up in canceling the job :-(

This behavior is caused by Flash calling the „onFileChunkComplete“-Event (or something) too often, or let’s say after every 4096 bytes sent, which can result in many many calls if you have a good upstream bandwidth.

Second, there are also those „unknown errors“ in Flash caused at runtime. The source yet is unknown and it seems to continue with Flash10 and  some little amount of customers smaller than one percent share. Sorry, unknown means unknown and Adobe won’t give support here! we’re back to Flash9 :-?

Yet the same thing happens to JavaScript if update goes too fast and too often, e.g. by using a progress bar constantly being updated (20-50times in the second). Therefore I had to split up the graphical update process to a seperate class that just goes on update intervals calling the current/total-values of the FileUpload-Class.

Well using Flash as upload client is nice, especially with the ability to use real sockets. For Flash9 the HTTP methods don’t provide the possibility of splitting large files – so you could upload them in seperate chunks. It’s about  security.

Then Flash10 possibly could do now (by accepting local files), but here we have the issue of having the upload beeing fired from Flash itself – scripting doesn’t work anymore, so no hidden flash uploader, that could do the job :cry:

But customer complaints still continues… especially form those using MSIE and don’t get a thing right.

PHP and APC, for now. HTTP again…

Okay, usually you gotta think this works now. It’s out now for long enough.  But fail of proof!

I leeched some script form PHPRiot yesterday by Quentin Zervaas, fixed some bugs (while(1=1) is great idea in JavaScript 8-O ), added a file limit check and hoped i finally would have something that really works.  But it didn’t:

  • Multiple file-fields do not work with APC
  • If file uploaded is greater than far greater than limit, apc throws out 0-values for current and total
  • Sometimes just seems stop working somehow; but after an apache restart apache it works again :cry:

I tried so many ‘solutions’ now and somehow it really seems to me, that monitoring the upload by calling a server-side status-script always has some problems. Probably it is really an Apache-issue… we’ll have too see…

Sliced HTTP Upload via Plugins – a solution?

I already mentioned it in the Flash/HTTP section, and indeed it’s more safe, because the file chunks are simply smaller!

I did many tests with Apache, and often it just happens that Apache closes a TCP connection on big file uploads. The source is yet unknown to me. Probably it has to do with Apache itself. I didn’t encounter the problem when using FastCGI and a Perl-Script to handle my upload.

So, i guess doing sliced upload is a good option. But then you could only use Flash10 which has other restrictions or Java. Yep, that thing that only works on 70-80%  of user browsers, MSIE for the rest that reports about having Java supported – true indeed – the other problem is: does it really run on those often misconfigured and compromised customer systems?

Well Flash10 now does, but have some limitations we probably could live with:

  • load() and save() APIs can only be called in response to user interaction (such as a button click).
  • locations of the loaded and save files are not exposed to ActionScript.

Since the API is now asynchronous (non-blocking),

Final match: HTTP vs. FTP-Uploads in the client

  • HTTP was not made for upload!
  • use more bandwidth than you actually need (base64!)
  • HTTP is not resumeable (but you could retry on splitted chunks)

Let’s summariuze: You can only monitor what was uplaoded by having control over your client and you can only split files, when you have access on it.

Use a Java-Applet or code a Flash-Client that works over FTP! And use a FTP-Server that is secure and can handle virtual users, like vsftpd. Then code some backend,

Yes! Probably it is a solution. But you still have the problems with users not supperting Java, or who complain about Java „loading“ too long. Here are some other good tries, that usually work:

We’ll see further when the first FTP libraries for Flash 10 are finished.

Archives Posts

FLEX has a new AJAX competitor: SmartGWT

Dezember 3rd, 2008 by Blu:RayNe

smartgwt-main-boFirst, I’m really astonished! SmartGWT – GWT NextGen – is here…

  • is fully done in AJAX, has therefore all the possiblities of XML
  • and so also XHTML and all the browser capabilites
  • is faster then the great Ext.JS
  • offers an increadibly amount of interface widgets
  • keeps beeing fast after loading a couple of examples
  • is easier to use probably easier to use than FLEX
  • because everything is done via server side Java Code
  • and it is licensed under LGPL!

Congratulations! This will set new standards for AJAX driven web applications… we will see how it compares to GWT-EXT 2 ;)

Archives Posts

Replacing adding or adding nodes in SimpleXML

November 18th, 2008 by Blu:RayNe

You just can’t! Because you only communicate with SimpleXML by getter and setter methods. It’s possible there is another interface – anywsy i doubt it!

So, the magic of adding nodes is to convert from and to DOMDocument. The snippet below is just something stripped from sourcecode, so you get the idea how it works.

// This document is emtpy –  it just illustrates an example!
$this->xml = simple_xml_load();

// convert base document from simplexml to dom
$dom = dom_import_simplexml($xml)->ownerDocument;

// get our nodes
$newNode = dom_import_simplexml($this->character->xml);
$oldNode = $dom->getElementsByTagName(‘character’)->item(0);

// import replacement node into our working DOM and reassign it
$newNode = $dom->importNode($newNode,true);

// for example: replace the -element in our DOM
$oldNode->parentNode->replaceChild($newNode, $oldNode);

// convert it back
$this->xml = simplexml_import_dom($dom);

Damn ugly but that’s just the way it is! :(

Filed under Allgemein, PHP having No Comments »

Archives Posts

Custom fonts: text replacement via Canvas and VML

Oktober 28th, 2008 by Blu:RayNe

Still we have to wait until @font-face is ready in all modern browsers. We had text-replacement by Flash, by images created on the server and by half-working SVG so far. Now it’s time for another approach: text replacement via pure Javascript!

Basically the script draws JSON font outlines converted via a Perl-Script from TTF and uses both VML and Canvas for rendering. Only problem: text cannot be selected and copied to the clipboard anymore.

There’s work left to be done. Planned improvements:

  • Full support for @font-face rules, if possible
  • Support for hinting (this seems like a viable option)
  • Speed improvements, especially for IE
  • Work around Opera’s getComputedStyle() issues
  • Possible support for SVG backend
  • Work around needing to specify ‘typeface-js’ as a class name
  • More CSS support, including :hover and x-height
  • React to DOMNode* events to support DHTML

 

Great job: It’s working on all major modern and semi-modern browser (MSIE7). I’ll be using that! Thanks!

More here: http://typeface.neocracy.org/

Filed under CSS, JavaScript having No Comments »

Archives Posts

Little bash snippet to kill locking queries from MySQL

Oktober 9th, 2008 by Blu:RayNe

I just tell you: optimize your tables! I will not give anymore support for bad code, stupid database layout and i am not going to debug your messy code. If you don’t get the introductino chapters of MySQL – stay away from me! Yep, it was just one of these days…

#!/bin/bash
echo "Killing MySQL Queries…"
MYSQL="$(which mysql)"
MyUSER="username"
MyPASS="password"

for pid in `mysqladmin proc  -u$MyUSER -p$MyPASS | grep -i Query  | grep -i lock|awk ‘{ print $2;}’`
do
        query="KILL $pid;"
        echo "> $query";
        $MYSQL -u$MyUSER  -p$MyPASS -e "$query"
done;

Filed under Datenbanken having No Comments »

Archives Posts

DOJO needs a package managment!

Februar 25th, 2008 by Blu:RayNe

I needed some locale date and number parsing fucntion for javascript today. As it goes for what the user sees i do usually do parsing and validation on the server-side. But this time i needed something for an admin interface that does also some javascript-based price calculation on the client-side.

So far i searched via Google for Prototype-based Libs on i18n, sprintf and so on. I found  JEL (JavaScript Enhancement Library)  and gave it try, but hardly to say: it is too bloated and the author implemented much english-language based method, but so far no sprintf, which i find is essential. And in overall the lib was ober 200KB for only doing I18n stuff!

Then i found out DOJO implements Date.POSIX and also a a String.sprintf that seemed very complete and began browsing the DOJO-Website. DOJO so far is IBM-sponsored and it was nice to see it reached a mature stage of development. I don’t like the namespaced function calls in JavaScript much, but on the server side doing java stuff like in GWT would be nice with that.

Still one big problem remains with DOJO: it just fucking hangs my browser and loads too damn slow!

DOJO has a nice dojo.require() which loads required dependencies on-the-fly. I had my own approach on that via the Prototype-based Postload.js. But the main problem with DOJO is that every class has again it’s own dependencies. You just have to inlcude one line of javascript in your HTML header, but when you do following require-statements…

dojo.require("dojo.date.locale");
dojo.require("dojo.currency");
dojo.require("dojo.i18n");

… it results in firing up about 40 requests on .js-files!  That’s horrible! No wonder, my little Firefox hangs until all files are loaded! So, please, don’t harm the web, DOJO!

I don’t know if there is any solution out by the DOJO team, so please tell me. My conculusion so far is that for default load process of the website the dependencies should be resolved before the page is even sent to the browser. The browser should have just to load one JavaScript-file that is compressed and contains all default dependencies used by DOJO on the page. So far that can only be done having a little reference of all dependencies, so the haeder can be written accordingly.

If there isn’t such a thing someone should do that! So far I think think DOJO is a good for my future use, as long as there isn’t an Prototype- or jQuery-equivalent for i18n. 

KAURI has also a nice comparision chart of JavaScript-libraries.

UPDATE #1: Probably i could now also check out localisation-support for Ext.js… which seems to miss parse()-functions (or does it automatically). And in overall i don’t find any great localisation support either :(

UPDATE #2: There seems to be such a thing for DOJO called DOJO Build System that uses ant. It could be used as base for automatic server-side file generation in PHP… great ;) I just everyone who uses DOJO is also using it, otherwise I am gonig to hate your websites!

Filed under Allgemein, JavaScript having No Comments »

Archives Posts

Prototip: Now does AJAX with this little Extension.

November 30th, 2007 by Blu:RayNe

Prototip.js is my favorite prototype.js-based tooltip-script at the moment. I’ve just written this piece in morning because we needed the capability of having dynamic content (or postloading big bits of HTML with images). Enjoy!

/**
 * AjaxTip
 * @version 0.1
 * @desc Extension for prototip.js. Now it supports dynamic loading of content. (http://www.nickstakenburg.com/projects/prototip/)
 * @author Markus Geiger 2007
 * @package AjaxTip
 * @license MIT
 * @url http://blog.evolution515.net
 */

var AjaxTip = Class.create(Tip, {
    hasContentLoaded: false,
   
    start: function() {
        this.require(‘Tip’);
    },
   
    initialize: function(elem, href) {
        this.elem = elem;
        this.href = href;
        this.options = arguments[3] || {};
        this.eventMousemove = this.mousemove.bindAsEventListener(this);
        elem.observe(‘mousemove’, this.eventMousemove);
    },
   
    mousemove: function(e) {
        if (this.tip)
            return false;

        // Initialize Tip
        var content = ‘<img alt="" src="lib/ajaxloader/tooltip.gif" style="vertical-align: top;" /> Loading&hellip;’;
        this.tip = new Tip(
            this.elem,
            content,
            this.options
        );

        // Make AJAX Request and load content
        var tip = this.tip;
        this.request = new Ajax.Request(
            this.href,
            {
                method: ‘get’,
                onSuccess: function(transport) {
                    tip.content = transport.responseText;
                    tip.tip.innerHTML = transport.responseText;
                }
            }
        );

        this.elem.tip = this.tip;
        Event.stopObserving(this.elem, ‘mousemove’, this.eventMousemove);
    }
});

And here’s a replacement for a better default CSS style:

/* Tooltip styles */
.prototip .default {
    width: 150px;
}
.prototip .default .toolbar {
    background: #FFE;
}
.prototip .default .title {
    padding: 5px;
}
.prototip .default .content {
    background: #FFE;
    font-size: 11px;
    font-family: Arial, sans-serif;
    padding: 6px;
    text-align:left;
    min-height:1em;
    width:200px;
    color:#000;
    border:1px solid #999;
    border-radius:5px;
    -moz-border-radius:5px;
}
 

You can create a neat AJAX-Loader GIF here. Use  #FFFFDD for background and #999999 for foreground color.

Filed under Allgemein, JavaScript having 3 Comments »

Archives Posts

Interactive Flash Panoramas

September 12th, 2007 by Blu:RayNe

I normaly don’t post much about Flash but this Interactive Panorama is really cool. It was built on Papervision3D, probably the most popular Flash 3D-Engine (but not as advanced as Away3D)

Somehow the stuff reminds me of the things that already were possible with quicktime, but were also harder to realizie and didn’t load as fast as Flash Panorama.

Filed under Flash having No Comments »

Archives Posts

PHP: Zend Framework Tutorial by Ralf Eggert

August 9th, 2007 by Blu:RayNe

I was a friend of Zend Framework when it was in version 0.5 because of the convincing and really well-thought concepts. Most of them are even better than those of CakePHP (ok, CakePHP can some little other frameworks can do much more than Zend Framework). But Zend Framework is now final and already 1.01, and i guess it has a bright future ;)

There is an easy to understand and some good tutorials on Ralf Eggert’s Blog that gives you an introduction to MVC and how things work with Zend Framework. Just try it for yourself!

And for all trolls: I know Java is better!

Filed under PHP having No Comments »

« Previous Entries