Windows 7 logon screen keyboard issue

My logon screen defaulted to US English or UK English keyboards and I was not able to log in efficiently.

Fixed with the following steps:

Open Windows Control Panel:

control_panel_region

Click on “Copy settings”:

logon_screen_1

Then check the first checkbox, followed by “OK”:

logon_screen_2

Executing WordPress shortcodes

By default, WordPress shortcodes can only be used in pages, posts and widgets.
If you want to include a shortcode for a cool plugin, or a special functionality you need, in your WordPress Template for example, you can use the following code to make it happen.

<?php echo do_shortcode('[shortcode goes here]'); ?>

Redirecting sub-domain to sub-directory

Recently I moved the EWEA blog from the sub-domain into the sub-directory of the EWEA website.

Before: http://blog.ewea.org/
After: http://www.ewea.org/blog/

To handle the redirect I put in the following into /etc/httpd/conf.d/vhosts.conf

<VirtualHost *:80>
# EWEA BLOG
ServerName blog.ewea.org
Redirect 301 / http://www.ewea.org/blog/
RedirectMatch 301 /(.+) http://www.ewea.org/blog/$1
ErrorLog  logs/blog.ewea.org-error_log
CustomLog logs/blog.ewea.org-access_log common
</VirtualHost>

The Redirect clause redirects all the traffic from the sub-domain to the sub-directory.
The RedirectMatch is to remap existing URLs to the sub-directory to avoid broken links.

(Taken from http://stackoverflow.com/questions/9397089/redirect-blog-mydomain-com)

Passwordless ssh for rsync, etc.

First you need to generate an RSA key on the source server.

ssh-keygen -t rsa

By default, the following files are created: /root/.ssh/id_rsa and /root/.ssh/id_rsa.pub.

Go to /root/.ssh/ and rename the files to the following format:

id_rsa –> server_prv_key and id_rsa.pub –> server_pub_key (where “server” is the hostname)

Next copy the contents across to destination server

Copy contents of server_pub_key and paste it into the /root/.ssh/authorized_keys on the destination server.

Now you can ssh without a password from one machine to another

ssh -p 10022 -i "/root/.ssh/server_prv_key" root@destination

Typo3 textarea

The latest version of Typo3 locks the frame of Quixplorer divs so you cannot resize the shape.

By editing this file:

/typo3/templates/template_page_backend.html

And adding:

###TITLE###
###META###
###CSS_INCLUDE###
###CSS_INLINE###
###JS_LIBS###
###JS_INCLUDE###
###JS_INLINE###
###HEADERDATA###
<!--###POSTJSMARKER###-->
<style type="text/css">
textarea {resize: auto;}
</style>
</head>
###BODY###
###JS_LIBS_FOOTER###
###JS_INCLUDE_FOOTER###
###JS_INLINE_FOOTER###
###FOOTERDATA###
</body>
</html>

I was able to unlock the resizing.

WordPress subnavigation accordian

See official documentation here:
http://codex.wordpress.org/Function_Reference/wp_list_pages

 

This here is the most interesting part (towards the bottom):

They can be styled with CSS selectors:

.pagenav { … } /* the outermost list item; contains whole list */
.page-item-2 { … } /* item for Page ID 2 */
.page_item { … } /* any Page item */
.current_page_item { … } /* the current Page */
.current_page_parent { … } /* parent of the current Page */
.current_page_ancestor { … } /* any ancestor of the current Page */

In order to achieve an accordion menu effect for instance, the following CSS can be used:

.pagenav  ul ul,
.pagenav .current_page_item ul ul,
.pagenav .current_page_ancestor ul ul,
.pagenav .current_page_ancestor .current_page_item ul ul,
.pagenav .current_page_ancestor .current_page_ancestor ul ul {
display: none;
}
.pagenav .current_page_item ul,
.pagenav .current_page_ancestor ul,
.pagenav .current_page_ancestor .current_page_item ul,
.pagenav .current_page_ancestor .current_page_ancestor ul,
.pagenav .current_page_ancestor .current_page_ancestor .current_page_item ul,
.pagenav .current_page_ancestor .current_page_ancestor .current_page_ancestor ul { 
display: block;
}

Restoring a single database from a complete MySQL database dump

Found here.

I had a collection of database dumps from a server that had been created using MySQL’s –all-databases option. This contained the databases for several Drupal websites, but I wanted to restore the Drupal database for just one of the sites. After a bit of Googling I came across two simple solutions:

The first option is to pass the whole SQL dump to MySQL command line, but restrict it’s operation using the “–one-database” option.

mysql -u root -p --one-database oneDB < fulldump.sql

In the above code substitute oneDB with the database name you want to restore, and fulldump.sql with the name of your full DB backup. If you would rather just extract the database dump of the single database from the –all-databases dump file, you can do this with sed using this command:

sed -n '/^-- Current Database: `oneDB`/,/^-- Current Database: `/p' fulldump.sql > oneDB.sql

Where dbname is replaced with the database name of the database to extract, and alldatabases.sql is the name of your dump file. The result will be saved into the file oneDB.sql.

Clear last search highlighting in VIM

By default in VIM, the last searched for word stays highlighted.
Adding this line:

nnoremap <esc> :noh<return><esc>

to this file:

~/.vimrc

allows you to clear the search highlighting just by tapping the ESC key.

Installing DenyHosts

Compiling and installing DenyHosts from source code on Centos 6.

[root@new denyhosts]# mkdir -p /root/Downloads/denyhosts
[root@new denyhosts]# cd $_
[root@new denyhosts]# wget http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fdenyhosts%2Ffiles%2Fdenyhosts%2F&ts=1343373868&use_mirror=freefr
[root@new denyhosts]# tar xzf DenyHosts-2.6.tar.gz
[root@new denyhosts]# cd DenyHosts-2.6
[root@new denyhosts]# python setup.py install
[root@new denyhosts]# cd /usr/share/denyhosts/
[root@new denyhosts]# cp -a denyhosts.cfg-dist denyhosts.cfg
[root@new denyhosts]# vi denyhosts.cfg
[root@new denyhosts]# cp -a daemon-control-dist daemon-control
[root@new denyhosts]# chmod 700 daemon-control*
[root@new denyhosts]# cd /etc/init.d
[root@new denyhosts]# ln -a /usr/share/denyhosts/daemon-control denyhosts
[root@new denyhosts]# dir
[root@new denyhosts]# service denyhosts
[root@new denyhosts]# service denyhosts start
[root@new denyhosts]# chkconfig denyhosts on
[root@new denyhosts]# tail -a /etc/hosts.deny
[root@new denyhosts]# vi /etc/hosts.deny
[root@new denyhosts]# tail -a /etc/hosts.deny
[root@new denyhosts]# vi /etc/hosts.deny
[root@new denyhosts]# vi /etc/denyhosts.conf ; service denyhosts restart
[root@new denyhosts]# cd /usr/share/denyhosts/
[root@new denyhosts]# dir
[root@new denyhosts]# ln -a /usr/share/denyhosts/denyhosts.cfg /etc/denyhosts.conf
[root@new denyhosts]# vi /etc/denyhosts.conf ; service denyhosts restart

http://www.linuxvadapav.com/security/how-to-install-denyhosts-on-centos-5-x-ubuntu-rhel-fedora.html

Javascript get GET variables from URL

function getQueryVariable(variable)
{
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
}

Usage

Example URL: http://www.example.com/index.php?id=1&image=awesome.jpg

Calling getQueryVariable(“id”) – would return “1”.
Calling getQueryVariable(“image”) – would return “awesome.jpg”.