Solution Vncviewer -via ssh tunnel with Vinagre

Vncviewer remote desktop connection
At work if I have to connect to a client’s Windows machine, I used to go in with Vncviewer through a ssh tunnel with the –via option like this:

vncviewer -via clienthostorIP usercomputername:0

No Scaling with Vncviewer
The other day I cam up against a client with Windows 7 and an enormous screen and found I couldn’t scale it small enough to not have to scroll up and down, left and right every 5 minutes to click on the task bar etc.

Vinagre
My boss suggested Vinagre so I had a Google for vinagre+vnc+ssh+scaling and found it has scaling, and has recently added ssh tunneling as an extra option for the Vnc connection.

Well, no matter what I tried I couldn’t get it to connect via vnc with the ssh tunnel option so I came up with a workaround. Just open a ssh tunnel first, and then connect with Vinagre.

Open two tabs or two screens in your Terminal
Tab/Screen 1: open a ssh connection from your clienthostIP to localhost:

ssh -C -L 5901:usercomputername:5900 clienthostorIP

Tab/Screen 2: Open vinagre against localhost:

vinagre localhost:1

Now you can connect to your client with Vinagre via a ssh tunnel and have access to scaling etc.

Perl script to import posts from WordPress to Whird blog

Just as a personal project with Perl and Mysql, I decided to start working on a Perl script to import posts from my WordPress blog to my Whird blog.

Whird
Whird was designed by Corenominal, the Crunchbang Linux head developer, and it looked like a nice platform so I installed it to use as a personal blog and leave the WordPress blog for Linux related posts.
It occurred to me that I may like to import some non-linux posts from WordPress, and that’s where my project began.

Perl vs Php
Although I love Perl, importing data from one site to another is far better suited to Php, something which Corenominal agreed with me on, but I decided to use Perl basically because, to me, Perl is king.

I would highly recommend Whird if you are looking for a new blogging platform which is light, fast, and offers you complete control over the design.

The script below was tested on my localhost installs and imported all the WordPress posts to Whird perfectly. However, it still needs some work to also include attachments, tags and comments. It’s also a vast improvement to my original script which was importing the posts from a wordpress.sql dump instead of the database-to-database connections.

#!/usr/bin/env perl
#########################################################
# SCRIPT TO IMPORT WORDPRESS POSTS TO WHIRD
# BY richs scadding - http://debianandi.blogspot.com
#########################################################
use strict;
use warnings;
use DBI;
use DBD::mysql;
#use Mysql;
#########################################################
# ENTER YOUR DATABASE DETAILS
# Assumes whird and wordpress databases are on same host
#########################################################
my $host = "localhost";
my $dbase = "whird";
my $dbase_orig = "wordpress";
my $login = "rich";
my $pw = "4321";
#########################################################
# GET POSTS FROM WORDPRES AND INSERT THEM INTO WHIRD
#########################################################
my $dbh=DBI->connect("dbi:mysql:$dbase:$host", $login, $pw);
my $dbhorig=DBI->connect("dbi:mysql:$dbase_orig:$host", $login, $pw);
my $sthorig = $dbhorig->prepare("select * from wp_posts");
$sthorig->execute;
while (my $ref = $sthorig->fetchrow_hashref) {
my $sql = "insert into whird_content (_date, _title, _excerpt, _content, _slug, _type) values (".$dbh->quote($ref->{post_date}).", ".$dbh->quote($ref->{post_title}).", ".$dbh->quote($ref->{post_excerpt}).", ".$dbh->quote($ref->{post_content}).", ".$dbh->quote($ref->{post_name}).", ".$dbh->quote($ref->{post_type}).")";
$dbh->do($sql);
}
$sthorig->finish;
$dbh->disconnect();
$dbhorig->disconnect();

Speed up Debian/Crunchbang dns name resolution: Faster Internet

This is just a little tip for those who don’t know about it yet. You may find that your internet connection is a bit slow, or your browser takes a while to connect to certain websites. Well this little bit of editing will provide you with a noticeable difference in speed when browsing the internet.

The problem lies in /etc/nsswitch.conf, so we just edit one line:
Comment out the “hosts:” line, and a new line minus “mdns4_minimal [NOTFOUND=return]” and “mdns4”, so that it only reads “files” and “dns”. [see below]

————————————————————————–
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference’ and `info’ packages installed, try:
# `info libc “Name Service Switch”‘ for information about this file.

passwd: compat
group: compat
shadow: compat

#hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
hosts: files dns
networks: files

protocols: db files
services: db files
ethers: db files
rpc: db files

netgroup: nis
—————————————————————————-

*Note* It’s always good practice to comment out and rewrite any changes you make on any system file, just in case you need to revert back to the default settings for any reason.