Chrom(ium) - thoughts

I have been using Chromium recently. It’s definitely quicker than Firefox and hasn’t crashed on me yet. I like how Adobe Flash doesn’t take the browser with it when it dies, just it’s element.

However I do have some irritations. I like to select text with the mouse as I read, helps me focus on the text more. Chromium has a very irritating habit of keeping things selected, and I have to scroll it off screen to remove it. This is however, nothing compared to the biggest annoyance…

Flash, crashes all the time. It’s very irritating. I can hardly use YouTube, and there is no way 1080p will work.

Very annoying.

That said, 100/100 on the Acid3 test!

How to harden a Gentoo server

A quick and dirty guide to hardening a Gentoo server. We will be using the hardened profile fom the Gentoo Hardened project.

First sync your portage tree.

# emerge --sync

Switch to the hardened profile. In this example, 5 is

# eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/10.0 *
  [2]   default/linux/amd64/10.0/desktop
  [3]   default/linux/amd64/10.0/developer
  [4]   default/linux/amd64/10.0/no-multilib
  [5]   default/linux/amd64/10.0/server
  [6]   hardened/linux/amd64/10.0
  [7]   hardened/linux/amd64/10.0/no-multilib
  [8]   selinux/2007.0/amd64
  [9]   selinux/2007.0/amd64/hardened
  [10]  selinux/v2refpolicy/amd64
  [11]  selinux/v2refpolicy/amd64/desktop
  [12]  selinux/v2refpolicy/amd64/developer
  [13]  selinux/v2refpolicy/amd64/hardened
  [14]  selinux/v2refpolicy/amd64/server
# eselect profile set 6

Now start screen (just incase) and emerge everything with the hardened toolchain. Go outside (yes, sun!), this will take a while…

# screen -S hardenme
# emerge binutils gcc virtual/libc
# emerge -e world

Now you need to install the hardened kernel.

# emerge -a hardened-sources
# eselect kernel list
# eselect kernel set

Now, because I am doing this on an OVH server at this point I use wget to obtain the .config for my current kernel. You should do this, or the equivalent for your set up (if you already have the .config, it’s fine). You must obtain the old .config, and place it in /usr/src/linux/.config thus removing the new one. Don’t worry, we’ll update it.

# cd /usr/src/linux
# make oldconfig

Now it will fix your old config to make it new and shiny. It’ll ask you questions, answer them!

# make menuconfig

Now to configure the kernel, enable PaX and grsecurity if you haven’t already. Set sensible options (read the help pages!)

# make
# make modules_install (if you have modules...)

Install the kernel how you usually would. (copy arch/***/boot/bzImage to /boot, etc.)

Reboot into your shiny new hardened set up!

# /sbin/shutdown -r now

And install chpax, paxtest, pax-utils, and paxctl.

# emerge pax-utils chpax paxtest paxctl

And read all about them! (You will need them to manage your new hardened set up).

Android apps I couldn’t live without…

Inspired by Ash, here’s a list of apps for my Android I couldn’t live without!

In no order…

HTC Sense
Interface for the HTC Hero. Very nice to work with and makes it look good. Quick too!

SwiFTP
Runs an FTP server on my phone. Great way to transfer files too it without the cable.

Seesmic
A Twitter client. I haven’t been using Twitter long, but I wouldn’t without Seesmic. It’s awesome.

WaPedia
Wikipedia client. Strips down articles so they’re quicker to load. Brilliant for looking something up in a low signal area.

NewsRob
Syncs my Google Reader RSS feeds to my phone. I always read the feeds while I’m on the bus to uni, and it’s very fast.

ConnectBot
SSH client. Enough said.

ASTRO File Manager
A really good file manager.

SMS Backup
Syncs my texts to my gmail account as emails. With the label “SMS” and without the label “Inbox”. This way they don’t appear under the normal inbox view.

AndFTP
FTP client. Enough said.

Facebook
…?

Meebo IM
A chat client that works with Facebook chat, MSN, AIM, etc.

DaraIRC
IRC client. Enough said.

Gmote 2
Remote control for my desktop. Mouse, keyboard, and music. Can stream music off my computer to my phone and listen to it in the kitchen. This way I have access to all my music, anywhere.

Google Maps
…?

Make the CapsLock key useful again...

Here’s a nice little trick to make the CapsLock key useful again…

xmodmap -e 'remove Lock = Caps_Lock'
xmodmap -e 'keysym Caps_Lock = Control_L'
xmodmap -e 'add Control = Control_L'

It’ll make CapsLock function as a Ctrl key. Where it’s supposed to be!

Sage

Sage is an awesome computer algebra system. It’s designed to be similar to Maple and Mathematica – but best of all it’s free and open source software!

Despite what it says in the README.txt, it may not be supported on Gentoo but it does compile on Gentoo with only mildly problems. All solvable. Mainly it’s just Fortran libs. Google will help you.

It has an awesome web based worksheet system, so you can use it anywhere in the world. At the moment, there is no Windows support. (Who needs it..?)

walld

A wallpaper daemon to switch wallpapers every 200 seconds. Nothing special. Have fun.

#!/usr/bin/perl
 
while(1) {
	my @walls = <~/gfx/wallpapers/*>;
	my $s = scalar @walls;
 
	my $f = @walls[rand($s)];
	print "Setting wallpaper -> $f\n";
	system("fbsetbg -a $f");
 
	sleep(200);
}
exit(0);

PhoneDaemon

My phone is capable of connecting to my wireless network. Here is a funky script I wrote in Perl while at uni. It turns my music on when my phone is connected to wireless, and off when it’s not. Static IP insures it never gets confused. In this script 192.168.1.102 is my phone.

#!/usr/bin/perl
 
use strict;
use warnings;
 
my $playing = 0;
 
while(1) {
 
	my $ping = `ping -c 3 -w 4 -q 192.168.1.102`;
 
	if ($ping =~ /[1-9] received/) {
		print "[-] Phone connected, playing music...\n" if $playing eq 0;
		system('mpc play') if $playing eq 0;
		$playing = 1;
	} else {
		print "[-] Phone disconnected, stopping music...\n" if $playing eq 1;
		system('mpc pause') if $playing eq 1;
		$playing = 0;
	}
 
	sleep(1);
}

Using JACK, for everything.

If you have ever used JACK before, you will know it’s a low-latency sound server daemon. It uses ALSA (or OSS, etc) as a backend, and allows you to do sound in realtime. It also handles communication between ‘jackified’ applications differently. You pretty much set them up in a similar way you would in a studio, plugging outputs into inputs, etc.

Anyway, JACK is used for sound production in Linux because ALSA, Pulseaudio, etc are far too slow. This is excellent, but there is a problem. Not all applications support JACK. Adobe Flash for example, does not.

For a long time this was a limiting factor for me, and the reason I only started JACK when I needed it. Not anymore! Here are a few simple steps to get JACK running all the time and not notice! (under Gentoo!)

You must add ‘jack’ to your USE flags, to get JACK support in all applications you have installed. Go ahead and update that.

emerge --ask --deep --newuse world

Things that will work without a problem are mpd, mplayer.

Next configure wine, by running winecfg and ticking JACK under sound. Untick ALSA.

Finally, the next step is to trick ALSA enabled applications into using JACK. Add the following lines to /etc/asound.conf

pcm.!default {
	type plug
	slave { pcm "jack" }
}
 
pcm.jack {
	type jack
 
	playback_ports {
 
		0 alsa_pcm:playback_1
		1 alsa_pcm:playback_2
 
	}
 
	capture_ports {
 
		0 alsa_pcm:capture_1
		1 alsa_pcm:capture_2
 
	}
}
 
ctl.mixer0 {
	type hw
	card 0
}

That’s it! Now Adobe Flash will work in Firefox! Go ahead and test it out! (you must have jackd running of course!)

It is useful to note that mpd will pick up JACK and ALSA when it starts, so if you only configure JACK in ~/.mpdconf it will work fine. Otherwise you will hear everything twice.

audio_output {
	type "jack"
	name "MPD JACK output"
}

This is great, but you will notice you must start jackd manually. This is tedious. Here’s how to set up an /etc/init.d script.

/etc/init.d/jackd

#!/sbin/runscript
# This programm will be used by init in order to launch jackd with the privileges
# and id of the user defined into /etc/conf.d/jackd
 
depend() {
	need alsasound
}
 
 start() {
	if ! test -f "${JACKDHOME}/.jackdrc"; then
		eerror "You must start and configure jackd before launch it. Sorry."
		eerror "You can use qjackctl for that."
		return 1
	else JACKDOPTS=$(cat "${JACKDHOME}/.jackdrc"|sed -e 's\/usr/bin/jackd \\')
	fi
 
	if [ -e /var/run/jackd.pid ]; then
		rm /var/run/jackd.pid
 	fi
 
	ebegin "Starting JACK Daemon"
	env HOME="${JACKDHOME}" start-stop-daemon --start \
			--quiet --background \
			--make-pidfile --pidfile /var/run/jackd.pid \
			-c ${JACKDUSER} \
			-x /usr/bin/jackd -- ${JACKDOPTS} >${LOG}
 
	sleep 2
 
	if ! pgrep -u ${JACKDUSER} jackd > /dev/null; then
		eerror "JACK daemon can't be started! Check logfile: ${LOG}"
 	fi
 
	eend $?
}
 
stop() {
	ebegin "Stopping JACK daemon -- please wait"
 	start-stop-daemon --stop --pidfile /var/run/jackd.pid &>/dev/null
 	eend $?
}	
 
restart() {
	svc_stop
	while `pgrep -u ${JACKDUSER} jackd >/dev/null`; do
		sleep 1
 	done
 	svc_start
}

/etc/conf.d/jackd

# owner of jackd process (Must be an existing user.)
JACKDUSER="<user>"
 
# .jackdrc location for that user (Must be existing, JACKDUSER can use
# qjackctl in order to create it.) 
JACKDHOME="/home/${JACKDUSER}" 
 
# logfile (/dev/null for nowhere)
LOG=/var/log/jackd.log

~/.jackdrc

/usr/bin/jackd -R -d alsa

This is just the arguments you would usually use to start jackd. You don’t need to install qjackctl if you know what you’re doing!

Finally add /etc/init.d/jackd to startup!

# rc-update add jackd default

And you’re done!

Facebook chat...

Has suddenly started using a *large* percentage of my CPU time when ever it does anything. I don’t understand why… Anyone here is my solution: install finch and the facebook chat plugin.

It’s easy with Gentoo:

echo "net-im/pidgin -gstreamer -gtk ncurses gnutls perl" >> /etc/portage/package.use
echo "x11-plugins/pidgin-facebookchat ~x86" >> /etc/portage/package.keywords
echo "dev-libs/json-glib ~x86" >> /etc/portage/package.keywords
 
emerge net-im/pidgin x11-plugins/pidgin-facebookchat

Done, start finch in screen for extra usability.

Maple is sorta cool...

> plot(x^2, x = -10..10);
 
  A                               100+                                   A 
   A                                 +                                  A  
   AA                                +                                 AA  
     A                               +                                AA   
      A                            80+                               A     
       A                             +                              A      
        AA                           +                            AA       
         A                           +                            A        
          AA                       60+                          AA         
           AA                        +                         AA          
             A                       +                        A            
              A                    40+                       A             
               AA                    +                     AA              
                 AA                  +                   AA                
                   AA                +                 AA                  
                    AAA            20+               AAA                   
                      AAA            +             AAA                     
                         AAA         +          AAA                        
                            AAAA     +      AAAA                           
  ++-++-+++-++-++-+++-++-++-+++-************-+++-++-++-+++-++-++-+++-++-++ 
 -10    -8     -6     -4     -2              2      4      6      8     10 
>

Funky.