Android: Move ringtones from SD-Card to internal memory

android-180I have a Motorola Milestone and keep it inside the Desk-Dockingstation all day long. While it is in there, the phone cant use the ringtones saved on the sd-card, because the sd-card is shared over USB. I simply moved my ringtone to the internal ringtone memory.


|Den ganzen Beitrag lesen...

Android: Install Google Mail in Cyanogen 7 and similar

android-180How to install Google Mail (GMail) on your Cyanogen Android Phone:

1. The Google Mail app is just available in USA Market. You need the app "Market Enabler" and fake a USA Provider like Verizon or T-Mobile.

2. Search for "Google Mail" or "Gmail" in the Market, if it does show up, install it.

3. If you cant find Google Mail in the Market, go to ww.appbrain.com and search for "Gmail". Use the QR Code + Browser to install Google Mail.

If you need any more Google Apps, check out this Wiki entry:
http://wiki.cyanogenmod.com/index.php?title=Latest_Version/Google_Apps

Firefox: Black form input fields when using a dark GTK / Gnome theme

firefox

I recently switched to a dark Gnome2 theme and realized, that firefox did use that colors too. But also firefox used these colors for the input forms on some websites. I found out how to partially fix this.


|Den ganzen Beitrag lesen...

PHP: Uncomment PHP Code

php-logo

If you want to uncomment your PHP Code, have a look at my script:

https://gist.github.com/1375986

Usage:

# php uncomment /path/to/file.php

The script will read the content of the file, remove the comment, and write back to the file.
So the file will be CHANGED! You have been warned.

PHP: The big php variable type casting!

php-logoI wrote a small script that does every available cast in PHP on every datattype.
Check it out on GistHub:
https://gist.github.com/1341572

The output of the script should be the following:

$ php casting.php

--- Casting all in PHP available Types in every way ---

Info:
In PHP we have the following data types: boolean, int, float, double, array, object,
while float and double should be the same.
There are other types that can not be created by cast, like resources.
PHP is weak typed and allows to cast everything to everything.
I think this is something every (good) Software Programmer working with PHP should know.
Check out the results of the casts, especially to boolean, so you do not need
if(strlen($s) > 0 || count($a) > 0) ... anymore.

PHP-Version: 5.3.5-1ubuntu7.3

--- casting 'null' ------------
(boolean)null -> (boolean)false
(int)null -> (integer)0
(float)null -> (double)0
(double)null -> (double)0
(string)null -> (string)''
(array)null -> (array)array ()
(object)null -> (object)stdClass

--- casting '0' ------------
(boolean)0 -> (boolean)false
(int)0 -> (integer)0
(float)0 -> (double)0
(double)0 -> (double)0
(string)0 -> (string)'0'
(array)0 -> (array)array (0 => 0,)
(object)0 -> (object)stdClass

--- casting '1' ------------
(boolean)1 -> (boolean)true
(int)1 -> (integer)1
(float)1 -> (double)1
(double)1 -> (double)1
(string)1 -> (string)'1'
(array)1 -> (array)array (0 => 1,)
(object)1 -> (object)stdClass

--- casting '0.0' ------------
(boolean)0.0 -> (boolean)false
(int)0.0 -> (integer)0
(float)0.0 -> (double)0
(double)0.0 -> (double)0
(string)0.0 -> (string)'0'
(array)0.0 -> (array)array (0 => 0,)
(object)0.0 -> (object)stdClass

--- casting '0.1' ------------
(boolean)0.1 -> (boolean)true
(int)0.1 -> (integer)0
(float)0.1 -> (double)0.1
(double)0.1 -> (double)0.1
(string)0.1 -> (string)'0.1'
(array)0.1 -> (array)array (0 => 0.1,)
(object)0.1 -> (object)stdClass

--- casting '1.23' ------------
(boolean)1.23 -> (boolean)true
(int)1.23 -> (integer)1
(float)1.23 -> (double)1.23
(double)1.23 -> (double)1.23
(string)1.23 -> (string)'1.23'
(array)1.23 -> (array)array (0 => 1.23,)
(object)1.23 -> (object)stdClass

--- casting 'true' ------------
(boolean)true -> (boolean)true
(int)true -> (integer)1
(float)true -> (double)1
(double)true -> (double)1
(string)true -> (string)'1'
(array)true -> (array)array (0 => true,)
(object)true -> (object)stdClass

--- casting 'false' ------------
(boolean)false -> (boolean)false
(int)false -> (integer)0
(float)false -> (double)0
(double)false -> (double)0
(string)false -> (string)''
(array)false -> (array)array (0 => false,)
(object)false -> (object)stdClass

--- casting '""' ------------
(boolean)"" -> (boolean)false
(int)"" -> (integer)0
(float)"" -> (double)0
(double)"" -> (double)0
(string)"" -> (string)''
(array)"" -> (array)array (0 => '',)
(object)"" -> (object)stdClass

--- casting '"abc"' ------------
(boolean)"abc" -> (boolean)true
(int)"abc" -> (integer)0
(float)"abc" -> (double)0
(double)"abc" -> (double)0
(string)"abc" -> (string)'abc'
(array)"abc" -> (array)array (0 => 'abc',)
(object)"abc" -> (object)stdClass

--- casting 'array()' ------------
(boolean)array() -> (boolean)false
(int)array() -> (integer)0
(float)array() -> (double)0
(double)array() -> (double)0
(string)array() -> (string)'Array'
(array)array() -> (array)array ()
(object)array() -> (object)stdClass

--- casting 'array(1)' ------------
(boolean)array(1) -> (boolean)true
(int)array(1) -> (integer)1
(float)array(1) -> (double)1
(double)array(1) -> (double)1
(string)array(1) -> (string)'Array'
(array)array(1) -> (array)array (0 => 1,)
(object)array(1) -> (object)stdClass

--- casting 'array(1, 2)' ------------
(boolean)array(1, 2) -> (boolean)true
(int)array(1, 2) -> (integer)1
(float)array(1, 2) -> (double)1
(double)array(1, 2) -> (double)1
(string)array(1, 2) -> (string)'Array'
(array)array(1, 2) -> (array)array (0 => 1,1 => 2,)
(object)array(1, 2) -> (object)stdClass

--- casting 'fopen("php://stdout", "w")' ------------
(boolean)fopen("php://stdout", "w") -> (boolean)true
(int)fopen("php://stdout", "w") -> (integer)6
(float)fopen("php://stdout", "w") -> (double)7
(double)fopen("php://stdout", "w") -> (double)8
(string)fopen("php://stdout", "w") -> (string)'Resource id #9'
(array)fopen("php://stdout", "w") -> (array)array (0 => NULL,)
(object)fopen("php://stdout", "w") -> (object)stdClass

--- casting 'new A()' ------------
(boolean)new A() -> (boolean)true
PHP Notice: Object of class A could not be converted to int in casting.php(67) : eval()'d code on line 1
(int)new A() -> (integer)1
PHP Notice: Object of class A could not be converted to double in casting.php(67) : eval()'d code on line 1
(float)new A() -> (double)1
PHP Notice: Object of class A could not be converted to double in casting.php(67) : eval()'d code on line 1
(double)new A() -> (double)1
(string)new A() -> (string)'A'
(array)new A() -> (array)array ()
(object)new A() -> (object)A

--- PROBLEMS ------------
Some constructs in PHP need a parameter type to work correnctly,
like foreach() and many functions like implode() ....

foreach(array("works") as $a) {}
PHP Warning: Invalid argument supplied for foreach() in casting.php on line 78
PHP Warning: Invalid argument supplied for foreach() in casting.php on line 79
PHP Warning: Invalid argument supplied for foreach() in casting.php on line 80
implode('', array("works"));
PHP Warning: implode(): Invalid arguments passed in casting.php on line 84
PHP Warning: implode(): Invalid arguments passed in casting.php on line 85
PHP Warning: implode(): Invalid arguments passed in casting.php on line 86

PHP: Playing with stdClass

php-logoI wrote some code to check what PHP included stdClass is capeable of.
You can find the code at gisthub:
https://gist.github.com/1309031

stdClass is really just a wrapper around a array that can be casted to a array.
Good thing about it is, you can extend it with some failsave __get($key) function.

PHP: Universal NULL Object

When working with interfaces you sometimes need a object as parameter. Thats why i wrote this primity universal null object that does nothing at all and does not throw any errors:

<?php
/**
* Universal NULL object.
*
* Will throw no error messages so can be used as universal parameter.
* Does overwrite all available magic methods used in PHP5.3.
*
* @author Julius Beckmann
*/

class NullObject {
  public function __construct() {}
  public function __destruct() {}
  public function __set($name, $value) {}
  public function __get($name) { return null; }
  public function __isset($name) { return false; }
  public function __unset($name) {}
  public function __call($name, $args) {}
  public function __toString() { return ''; }
  public function __invoke() {}
  public function __clone() {}
  public static function __callStatic($name, $args) {}
}

GistHub:
https://gist.github.com/1101526

The project triangle

Anybody of you who worked in a (bigger) project, might have noticed that there are always problems about specific factors like time, money and quality.
While getting my Scrum Master certificate, our teacher told us about something called the "project triangle".

|Den ganzen Beitrag lesen...

PHP: Doing some cool things with references and destructors

php-logo
Not everybody of you might know, that there are references in PHP too, like in many other languages. I wondered if there is something these references might be really good for and came up with the following concept.

|Den ganzen Beitrag lesen...

Ubuntu: Create own or fix broken samba shared directorys

ubuntu_logoI recently wanted to create a shared folder with the attribute hidden, but did not want to change the /etc/samba/smb.cnf.

So i searched where the shares created by the gnome folder-properties window where saved. The directory is:

/var/lib/samba/usershares/

This is also the place, where you might fix a broken share by deleting the config file.