virtualbox not identified network

When you install Virtualbox on Windows Vista or Windows 7 it will install an additional virtual network adapter on the host system. This “Virtualbox Host-Only Adapter” causes the Windows network detection to show an additional “unidentified” network. And while this “unidentified” network is present the windows firewall settings will stay on “Public”. This behavior is undesirable because you want to be able to switch your firewall settings based on your location (home/work/public).

virtualbox not identified network

The solution: Edit your registry and make that networks a NdisDeviceType.  Open regedit and navigate to HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
Browse through the subkeys (named 0000, 0001, etc) until you find the subkey containing the virtualbox network adapter, this is the one where the “
DriverDesc” key has “VirtualBox Host-Only Ethernet Adapter” as value.  Add a new DWORD value with a name of “*NdisDeviceType” and a value of “1” Disable en re-enable the virtuabox host-only network adapter.

Why that works? From http://msdn.microsoft.com/en-us/library/bb201634.aspx

*NdisDeviceTypeThe type of the device. The default value is zero, which indicates a standard networking device that connects to a network. Set *NdisDeviceType to NDIS_DEVICE_TYPE_ENDPOINT (1) if this device is an endpoint device and is not a true network interface that connects to a network. For example, you must specify NDIS_DEVICE_TYPE_ENDPOINT for devices such as smart phones that use a networking infrastructure to communicate to the local computer system but do not provide connectivity to an external network.

 

Good bye spam!

Since the spam increased that much up to 10k spam each week I searched for a solution. It came out that the combination of Akismet and Stop Spammer Registrations Plugin made it possible to have only 1 or 2 spam comments in the queue. I love it!

Good bye de@r spam!

Javascript money format

Number.prototype.moneyformat = function(decPlaces, thouSeparator, decSeparator) {
	var n = this,
	sign = n < 0 ? "-" : "",
	i = parseInt(n = Math.abs(+n || 0).toFixed(decPlaces),10) + "",
	j = (j = i.length) > 3 ? j % 3 : 0;
	return sign + (j ? i.substr(0, j) + thouSeparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouSeparator) + (decPlaces ? decSeparator + Math.abs(n - i).toFixed(decPlaces).slice(2) : "");
};

usage:

var myMoney=3543.75873;
var formatedMoney = myMoney.moneyformat(2,'.',',') + ' EUR';

Akismet blows commentmeta wordpress

Today I noticed that the commentmeta table in the DB was huge, even the fact that I delete my spam daily. I saw that the commentmeta table had a size of 1,5 MB compared to the other tables with a few kb. I figured out that Akismet plugin caused that. I love that plugin cause it saved me a lot of time filtering the spam comments, but blowing my db is another thing. I have more than this blogs running with much more content. There is might be more trouble with the increase of the table.
However I executed the following query and the size of that table was only 7 kb. Woot!

DELETE FROM `wp_commentmeta` WHERE 
 `meta_key` = 'akismet_as_submitted' 
 OR `meta_key` = 'akismet_history' 
 OR `meta_key` = 'akismet_rechecking'
 OR `meta_key` = 'akismet_result' 
 OR `meta_key` = 'akismet_user' 
 OR `meta_key` = 'akismet_user_result';

Javascript get type

Get the type in javascript

var TYPES = {
    'undefined'        : 'undefined',
    'number'           : 'number',
    'boolean'          : 'boolean',
    'string'           : 'string',
    '[object Function]': 'function',
    '[object RegExp]'  : 'regexp',
    '[object Array]'   : 'array',
    '[object Date]'    : 'date',
    '[object Error]'   : 'error'
},
TOSTRING = Object.prototype.toString;

function type(o) {
    return TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? 'object' : 'null');
};

jQuery UI autocomplete mustMatch Ersatz

jQuery UI autocomplete versagt leider, wenn nur Begriffe aus der Liste ausgewählt werden dürfen. Die eingebaute option mustMatch: true funktioniert leider gar nicht. Deshalb eine Funktion, die Abhilfe schafft.

function jQueryUIAutoCompleteMustMatch(input) {
    var found = 0;
    var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( jQuery.trim($(input).val()) ) + "$", "i" );
    jQuery.each($('.ui-autocomplete li'), function(i, val) {
        if(jQuery.trim( $(val).text() ).match( matcher ) ) {
            found = 1;
        }
    });
    if (found) {
        return true;
    }
    else
    {
        $(input).val('');
        return false;
    }
}

Und dann

change: function(event, ui) {
                jQueryUIAutoCompleteMustMatch($(this));
            }

jQuery zoom with all browers

Well all browsers can do the same, except for Firefox. Wired, indeed! However this zoom script works in IE, Firefox,Chrome,Safari.

jQuery(document).ready(function() {
    var currFFZoom = 1;
    var currIEZoom = 100;

    jQuery(".make_greater").click(function(){
        var step;
        //only firefox sux in this case
        if (jQuery.browser.mozilla){
            step = 0.05;
            currFFZoom += step;
            jQuery('.maincontent').css('MozTransform','scale(' + currFFZoom + ','+ currFFZoom + ')');
            jQuery('.maincontent').css('transform-origin','0 0');
        }
        else
        {
            step = 5;
            currIEZoom += step;
            jQuery('body').css('zoom', ' ' + currIEZoom + '%');
        }
    });

    jQuery(".make_smaller").click(function(){
        var step;
        //only firefox sux in this case
        if (jQuery.browser.mozilla){
            step = 0.05;
            currFFZoom -= step;
            jQuery('.maincontent').css('MozTransform','scale(' + currFFZoom + ','+ currFFZoom +')');
            jQuery('.maincontent').css('transform-origin','0 0');
        }
        else
        {
            step = 5;
            currIEZoom -= step;
            jQuery('body').css('zoom', ' ' + currIEZoom + '%');
        }
    });
});
jquery zoom source
jquery zoom

jQuery load and execute javascript / js and css file

if (jQuery('.startseitenslider').length > 0){
        jQuery('head').append('<link>');
        jQuery('head').children(":last").attr({
            rel:    "stylesheet",
            type: "text/css",
            href: "../css/nivo-slider.css"
        });

        function init_slider(){
            //$('#slider').nivoSlider();
        }
        jQuery.getScript("../js/jquery.nivo.slider.pack.js", function(){
            //wait before initialising to prevent intermittent load error
            setTimeout(init_slider,250);
        });
    }

jQuery wait

jQuery.fn.wait = function(time, type) {
    time = time || 1000;
    type = type || "fx";
    return this.queue(type, function() {
        var self = this;
        setTimeout(function() {
            jQuery(self).dequeue();
        }, time);
    });
};
Anwendung:
jQuery(SELECTOR).wait().css('display','block');

MySQL UTF-8 fix Umlaute

Geht ziemlich schnell Sonderzeichen zu reparieren in MySQL! Scheiß Encoding! ;)

UPDATE `table` set
    `column`= REPLACE(`column`,"ß", "ß"),
    `column`= REPLACE(`column`, "ä", "ä"),
    `column`= REPLACE(`column`, "ü", "ü"),
    `column`= REPLACE(`column`, "ö", "ö"),
    `column`= REPLACE(`column`, 'Ä', 'Ä'),
    `column`= REPLACE(`column`, "Ãœ", "Ü"),
    `column`= REPLACE(`column`, "Ö", "Ö"),
    `column`= REPLACE(`column`, '€', '€');

Archive for category Technik

Archives by Month: