Articles in the General Category
Posted: May 08 | Filed under: General
If you got an image inside a td using the img html tag and you want to center the table in firefox it will sometimes not do it properly.
It helps to add style=”text-align:center;width:xxx;” to the img tag.
Posted: May 05 | Filed under: General
Today I have found this little snippet to retrieve a page to save it in a variable e.g. $content.
$handle = fopen($location, "r"); if($handle) { $contents = ''; while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle);
You want to know what the 8192 does? It’s the byte data the browser retrieves before saving it into $contents.
Posted: May 04 | Filed under: General
It’s strange but a lot of elements like active-x controls are always on top of other div’s even if you defined a z-index:0 for that element and the div has a z-index:1.
An easy solution would be to hide the objects while the menu is active, this can be realized with a “getElementsByClass. ” functions, which I have found here webdesignblog.de.
Without a getelementbyclass it’s sometimes difficult to hide your navigation with javascript. This little script will help you to realize just that.
function hide() { var allElems = document.getElementsByTagName('*'); for (var i = 0; i < allElems.length; i++) { var thisElem = allElems[i]; if (thisElem.className && thisElem.className == 'CLASSNAME') { thisElem.style.display = 'none'; } } } function show() { var allElems = document.getElementsByTagName('*'); for (var i = 0; i < allElems.length; i++) { var thisElem = allElems[i]; if (thisElem.className && thisElem.className == 'CLASSNAME') { thisElem.style.display = 'block'; } } }
Replace CLASSNAME with the name of your nav class.
Then simply call the script like that:
<li onmouseover=hide(); onmouseout=show();> navigation</li>
This is of course not a solution for embed window media player streams, because it will reload the stream everytime.
I’m currently trying to find a solution for the embed wmp.
Update:
Here is a solution for the embed wmp, I hope that can help you.
asp.net
Posted: Apr 13 | Filed under: General
The bash_history is a file that saves your command line entries. If you execute any commands via SSH it will save them in the file .bash_history, so that you are able to quickly execute older commands again.
However you can imagine that this is a security risk you can easily avoid by cleaning the history after you logout.
First of all you should locate your bash_history.
Nothing easier than that, simply execute:
“locate bash_history” via SSH and it will show you where it is.
The File “.bash_profile” should be in the same directory.
Now either use a SSH editor like nano to open the file “.bash_profile” or simply open it via WINSCP. This is really a personal taste but I prefer using nano instead of vim because it’s easier to handle. Execute “nano .bash_profile”. If it’s in a subdirectory then you will have to “cd” there.
Now add the following lines at the very end:
export HISTSIZE=100
export HISTFILESIZE=100
unset HISTFILE
You can change “100″ to the number of commands you want to keep while being logged on. If you logout it will “unset” everything and delete your commands.
VoilĂ ! Now it will automatically delete your bash_history if you logout.
Posted: Mar 29 | Filed under: General
Today I had to convert a multidimensional array and found a very simply solution at PHP.net that I want to share with you.
A multidimensional array is an array that stores arrays. Usually a normal array is easier to handle, that’s why converting the array is a good solution.
That will turn this:
Array
(
[1] => Array
(
[0] => 1
[1] => 2
)
[2] => Array
(
[0] => 3
[1] => 4
)
)
Into this simple array:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
Here’s the very efficient and short code:
function flatten_array($value, $key, &$array) {
if (!is_array($value))
array_push($array,$value);
else
array_walk($value, 'flatten_array', &$array);
}
Then you are able to to use “array_walk”, simply rename $oldarray to the name of your multidimensional array!
$newarray = array();
array_walk($oldarray, 'flatten_array', &$newarray);
Happy converting !
Posted: Mar 29 | Filed under: General
Let’s say you got a table with lots of entries that have the same value and you want to safe each entry in an array even if it’s a “duplicate”, you can do it with a simple SQL query:
$query = $db->query("SELECT * FROM $db->tablename where exists ( SELECT tablerow_name FROM $db->tablename) ") ;
I hope that helps a bit


