Dark Launch

This is a Dark Launch.

Vim replace tabs with spaces

To replace all tabs with 4 spaces in vim using the following command:

Code
:%s/\t/    /g
 

Explained:

Code
: - command
%s - entire selection
/ - separator
\t - search for tab
/ - separator
"    " - replace with 4 spaces
/ - separator
g - global replace
 

Fix to "fuse: device not found, try 'modprobe fuse' first" for ssh

To fix the error: "fuse: device not found, try 'modprobe fuse' first", do the following on the command line:

Code
modprobe fuse
 

Then retry your sshfs command.

Use Firebug Lite in Internet Explorer on any page

Use Firebug Lite in Internet Explorer on any page with a simple copy and paste in the URL bar. Firebug provides a lite version for IE to inspect page elements and perform of functions as well.

To use Firebug in older versions of Internet Explorer, simply copy and paste the following code into the url and click "Go" or hit the enter key. The code will append the firebug lite script for use on the page and the firebug icon will appear in the bottom right on the page.

Javascript
javascript:var script = document.createElement("script"); script.type = "text/javascript"; script.src = "https://getfirebug.com/firebug-lite.js"; document.getElementsByTagName("body")[0].appendChild(script); void(0);

To also open the console, use the following code instead:

Javascript
javascript:var script = document.createElement("script"); script.type = "text/javascript"; script.src = "https://getfirebug.com/firebug-lite.js"; document.getElementsByTagName("body")[0].appendChild(script); script.onreadystatechange = function() { if (script.readyState == "complete") { console.open(); }} void(0);
UPDATE: This method mentioned worked in older versions of IE. For newer versions, use the bookmarklet method. That is, drag the bookmarklet on firebug lite's download page ( http://getfirebug.com/firebuglite ) to your favorites bar. When on the page you want to debug, click the bookmark. Try each of the bookmarklet versions if the stable version doesn't work for you.

PHP get the name of the given variable used using var_name()

Using PHP it is possible to get the given variable name as a string -- similar to using the function get_defined_vars() for a traceback.

A possible use case is a situation like a traceback where you call a function with a parameter and you need to know which variable was passed to the original function.

PHP
<?php
function var_name(&$var) {
   foreach ($GLOBALS as $k => $v) {
       $global_vars[$k] = $v;
   }
 
   // save the variable's original value
   $saved_var = $var;
 
   // modify the variable whose name we want to find
   $var = !$var;
 
   // compare the defined variables before and after the modification
   $diff = array_keys(array_diff_assoc($global_vars, $GLOBALS));
 
   // restore the variable's original value
   $var = $saved_var;
 
   // return the name of the modified variable
   return $diff[0];
}
PHP
header('Content-Type: text/plain');
 
$some_var_name = 'some value foo';
$another_var_name = 'bar';
$yet_another_var = 'baz';
 
echo '$' . var_name($some_var_name) . ' = ' . $some_var_name . "\n";
echo '$' . var_name($another_var_name) . ' = ' . $another_var_name . "\n";
echo '$' . var_name($yet_another_var) . ' = ' . $yet_another_var . "\n";

The above code will produce the following output:

Code
$some_var_name = some value foo
$another_var_name = bar
$yet_another_var = baz
 

Ubuntu play restricted DVD. Fix "This may be because the DVD is encrypted and a DVD decryption library is not installed."

To fix the following DVD error: "This may be because the DVD is encrypted and a DVD decryption library is not installed.", you need to install libdvdread4 to play your DVD as it is likely encrypted. Open the Terminal and on the command line, copy and paste the following commands to run them:

Code
sudo apt-get install libdvdread4
cd /usr/share/doc/libdvdread4
sudo bash install-css.sh
 

This will allow playback of commercial DVDs that are encrypted with CSS (Content Scrambling System) and your disc should now be able to play as intended.

Also, please use VLC Media Player http://www.videolan.org/

Enjoy your movie.