Archive

Author Archive

Star Wars floppy disk

February 10, 2011 Leave a comment

The Force is strong with this floppy:

I found this video in this post (follow this link for more videos).

Categories: fun Tags: , , ,

phpMyAdmin: No activity within 1440 seconds; please log in again

February 10, 2011 12 comments

Problem

phpMyAdmin’s “No activity within 1440 seconds; please log in again” message is slowly but definitely driving you crazy. How to remain sane?

Solution

Increase the time limit. Open the file /etc/phpmyadmin/config.inc.php and add the following line to its end:

$cfg['LoginCookieValidity'] = 60 * 60 * 8;  // in seconds (8 hours)

Here I set 8 hours, but you can change that.

When you log in again in phpMyAdmin, this new value will be taken into account.

Categories: php Tags: , , ,

Command line calculator with Python

February 10, 2011 3 comments

Problem

You use the command line terminal a lot and sometimes you need a simple calculator. Is one available in command line?

Solution

Of course. It’s called Python interpreter :) Python is usually available everywhere and its command line interpreter is a perfect calculator too.

Example:

C:~> python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 45 + 98
143
>>> _ + 7
150
>>> _ / 2.0
75.0
>>>

Cannot be any simpler. As you can see, the special variable ‘_‘ (underscore) gets the value of the previous computation. Division between two integers returns the whole part, thus 7 / 2 is 3. What you need is usually 7 / 2.0, which is 3.5.

You can quit with CTRL+D.

Tip

I use this calculator quite often, so I added the following line to my ~/.bashrc:

alias p='python'
Categories: bash, python Tags: ,

Learn GIMP with GIMPtricks

February 10, 2011 Leave a comment

Would you like to learn to use a powerful image editor? Do you find Photoshop too expensive and too complicated? Are you looking for a free alternative? Then you should learn GIMP! If you don’t know how to get started, visit GIMPtricks’s channel at YouTube.

GIMPtrick is a Dutch girl who can explain everything about GIMP in a very clear and understandable way. If you’ve never used GIMP, start with her beginner tutorials.

Categories: gimp Tags: , ,

HTML automatic redirect

February 9, 2011 2 comments

Problem

You have an HTML page and you want to redirect the user to a new page in X seconds, i.e. in X seconds you want to load another page.

Solution

<html>
<head>
<title>Title of the Page</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.example.com">
<link rel="stylesheet" type="text/css" href="assets/style.css" />
</head>
<body>
...
</body>
</html>

What we need here is line 5:

<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.example.com">

Meaning: you will be redirected immediately (in 0 seconds) to http://www.example.com. You can change 0 to X, which means that redirection will be done in X seconds (where X is a positive integer).

Credits

I found this tip here.

Categories: html Tags: ,

Getting started with the Haskell programming language

February 9, 2011 Leave a comment

Some quotes from Wikipedia:

Haskell is a standardized, general-purpose purely functional programming language…
The language continues to evolve rapidly, with the Glasgow Haskell Compiler (GHC) implementation representing the current de facto standard.
It is a purely functional language, which means that in general, functions in Haskell do not have side effects.
There is an active community around the language, and more than 2600 third-party open-source libraries and tools are available in the online package repository Hackage.

Installation

sudo apt-get install haskell-platform

Hello, World! (compiled)

Create the file hello.hs:

main = putStrLn "Hello, World!"

Compile it:

ghc hello.hs -o hello

Run it with ./hello.

Hello, World! (interpreted)

#!/usr/bin/runghc

main = putStrLn "Hello, World!"

Then “chmod u+x hello.hs” and “./hello.hs“.

Tutorials

There are tons of tutorials on the Web.

Links

How good are you in Vim?

February 9, 2011 Leave a comment

If you think you are a Vim power-user and there is nothing new to learn, check out VimGolf. On this site you will find various challenges, and by submitting your own solution, you can earn scores. The goal is to improve your knowledge about Vim. If you are really good, you may get on the leaderboard.

I looked at some solutions and they look like a Perl nightmare :) Even if you don’t want to dive in, you can have a look at the “Resources for learning Vim“. I copy them here too:

(Thanks Fred for the link).

Categories: vim Tags:

Play WebGL games and demos

February 9, 2011 Leave a comment

PlayWebGL.com is dedicated to WebGL technology. You’ll find on this website many games, demos and everything else related to WebGL.

Check out their FAQ to learn more about WebGL, what browser you need, and what games/demos are available.

Extra for me: they have Quake 2, which was one of my favorites “some” years ago.

Categories: Uncategorized Tags: , , ,

Emulate the MS-DOS prompt

February 8, 2011 1 comment

MS-DOS prompt

If you miss the MS-DOS times :), here is how to emulate the DOS prompt in bash.

Version #1

Here is the basic version:

export PS1='C:\w> '

To make it permanent, add it to your ~/.bashrc file :)

Result:

C:/> cd /tmp
C:/tmp> cd /etc/grub.d/
C:/etc/grub.d>

Version #2

Here is how to replace the ‘/‘ characters to ‘\‘ in the prompt path. First, add the following function to your ~/.bashrc:

function msdos_pwd {
   echo `pwd` | tr '/' '\\'
}

Then, either source ~/.bashrc, or open a new terminal window.

Finally, set PS1 like this:

export PS1='C:`msdos_pwd`> '

Result:

C:\> cd /tmp
C:\tmp> cd /etc/grub.d/
C:\etc\grub.d>

Improvement #1:

If you want to see ‘~’ instead of full path when you enter your HOME directory, use this function:

function msdos_pwd
{
    if [ "`pwd`" == "$HOME" ]
    then
    echo '~'
    else
    echo `pwd` | tr '/' '\\'
    fi
}

Improvement #2 (update 20110210):

The previous version showed ‘~’ in the HOME directory only. When you entered a subdirectory of HOME, HOME was expanded. Here is the revised version:

function msdos_pwd
{
    local dir="`pwd`"
    dir=${dir/$HOME/'~'}

    echo $dir | tr '/' '\\'
}

Links

Similar work (update 20110210)

As I was browsing the web looking for something alike, I found a similar approach. His implementation is different and he doesn’t replace the HOME directory by ‘~’.

Blinking cursor (update 20110304)

In MS-DOS, the cursor was a blinking underscore. Here is how to set it under Konsole: Settings -> Configure Profiles… -> Edit Profile… -> Advanced tab. Here, under the Cursor section, tick Blinking cursor and for cursor shape select “Underline”. Apply, OK. Close konsole and open a new instance.

Final touch (update 20110311)

To make it even better, let’s print some MS-DOS boot text when opening a new shell. Add these lines to the end of your ~/.bashrc file:

echo Starting MS-DOS...
echo
echo
echo HIMEM is testing extended memory...done.
echo

You can download everything here.


Screenshot of the final product.

Update (20120927)
On reddit, someone suggested the following one-liner:

export PS1='C:${PWD//\//\\\\}>'
Categories: bash, fun Tags: , ,

Patch to Google Translate https pages

February 7, 2011 10 comments

Problem

When you want to translate a page with Google Translate that uses the HTTPS protocol, you will get an error. Translation only works with HTTP addresses. Here is how to reproduce the problem:

You will get a beautiful “Sorry, this URL is invalid” error.

Explanation:

This a known bug on the side of Google but they don’t rush to correct it. In the address bar you have the string “http://translate.google.com/translate?js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&sl=auto&tl=en&u=https%3A%2F%2Fubuntulife.wordpress.com%2F”. Notice that the address to be translated begins with https. In the upper frame, Google Translate transforms this address to “http://ubuntulife.wordpress.com:443/&#8221;, i.e. port 443 is added automatically.

Update (20110211): Google has a clarification. In this thread, Google guy Josh says the following: “Currently our webpage translation service will not translate secure https pages. This is because such pages often have secure content, that you wouldn’t want to send over the wire plain text to Google Translate.” That is, they know about this problem but they don’t have a good solution.

Manual workaround #1:
Remove the port “:443” from the Google Translate textfield and press the button Translate.

Manual workaround #2:
In the address bar, locate the string https and change it to http. Then press Enter to reload the page. The port “443” will also disappear.

Workaround for the lazy ones

Let’s use a simple bookmarklet that implements the manual method #2:

javascript:
var l = document.location;
var h = l.href;
var https = encodeURIComponent('https://');   // https%3A%2F%2F
var http = encodeURIComponent('http://');   // http%3A%2F%2F
l.href = h.replace(https, http);
void(1);

Installation:
Open this page in a new tab. There, you will find a link “ReTr” (re-translate). Drag and drop that link to the bookmark bar.

Usage:
Once the ReTr (re-translate) bookmarklet is installed, try to translate an HTTPS page. When you get the error message, just click on the ReTr bookmarklet and the page should be translated correctly.

Translate with Flagfox

Flagfox is a Firefox add-on that can “display a country flag depicting the location of the current website’s server and provides a multitude of tools such as site safety checks, whois, translation, similar sites, validation, URL shortening, and more…

How to translate a page with Flagfox: right click on the country flag in the address bar -> select Google Translate. You will get an error message with HTTPS pages, but you can correct it with the previously mentioned “ReTr” bookmarklet.