Saturday, March 12, 2011

HOWTO Troubleshoot windows sound problems (for parents using google video chat)

The good people at google, have a nice parent-friendly intro to video chat. Unfortunately, getting to the point of having a gmail account with the plugin installed, is, in my experience, the easy part.

The bigger challenge is troubleshooting audio problems, and the google troubleshooting page doesn't offer much help, apart from a weird endorsement of Logitech products.  For the people I chat with, the problem is usually a muted microphone, and/or muted sound.  Instructions for modifying sound setup on Windows 7 are below.

Look at the bottom right corner of the screen for the speaker icon


Left click the speaker, and make sure the volume is turned up


Check if that solves the problem.  If not, right click the speaker and choose playback devices


Click Properties


and check the slider is turned up on the Levels tab.



 
Click OK, and get out to the desktop.
 
Right click on the speaker again to check your microphone.  Click recording devices.
 
 
 The green bar should move up and down as it registers sound.  Try talking.

 
If that all looks OK, google provides an interface for you to check your settings from within gmail.  
 
Login and click on the settings link on the top right corner


Then click on the chat tab


and on the + sign next to "Verify your settings".


If you answer 'Yes' to all three questions in that box, and you still don't have working audio or video, you can tell the person on the other side that it is a problem on their end, and point them to these instructions :)

HOWTO Create multiple chrome and firefox profiles on linux

I like using multiple browser profiles for security reasons. I keep my valuable cookies, such as those for email etc. in one profile, and do regular web-browsing in another. This means if I hit a XSS through regular browsing, the scope for cookie stealing is limited. When using firefox with the noscript plugin it also makes sense to have different whitelists for these two usage scenarios.

Creating firefox profiles is simple, just use the profile manager, which you can bring up with:
firefox --no-remote -P

Once you have created the profile, I copy the shortcut icon and change the target to point at the new profile like this:
firefox %u --no-remote -P browse

Chrome is almost as easy, but the doco can be a little harder to find. You just need to specify a new user data directory like this:

/usr/lib/chromium-browser/chromium-browser --enable-udd-profiles --user-data-dir=.config/google-chrome/Browse

and change your shortcut icon to run the same command.

On Ubuntu natty and oneiric this got harder with the new launcher. There are a lot of ways to get it done, but this seemed the simplest to me:
sudo apt-get install alacarte gnome-panel
  • Start "Main Menu" by searching for it in the dash.
  • Add an item for your application and close the editor.
  • Logout to refresh the dash (there must be a way to do this without a logout, but not sure what it is).
  • Start the application by searching for it in the dash.
  • Right-click on the icon and "Keep in launcher"

I also created a couple of (ugly) custom icons to keep my 'Browse' and 'Mail' profiles clearly marked.

Monday, January 24, 2011

HOWTO add a directory to your python path

You can add to your python path like this:

import sys
sys.path.append("/home/me/mypy") 

The (python) way of the future: pip and virtualenv

I recently discovered the magic of pip and virtualenv. Pip is shaping up as a serious contender for replacement of distutils and easy_install. I haven't used it much yet, and will have to reserve judgement until I package a decent-sized project with pip.

Using pip is easy, although there is a bootstrapping problem that, ironically, I used easy_install to solve. If your distro packages a recent version of pip, you can use it to skip this bit.

sudo apt-get install python-setuptools
s easy_install pip
s pip install virtualenv

This gives you a virtualenv install. Virtualenv is brilliant, and has significantly influenced the way I write python. Virtualenv allows you to build a complete python environment in a directory that you 'activate' by running an in-built shell script that sets your python path environment variables. The are many advantages to this approach, but here are a few I have encountered:
  • Simplified testing - test your code against multiple versions of libraries and utilities
  • Keep separate dev and production environments on your dev machine, allowing you to test in a production environment without pushing the code to your actual production server.
  • The isolation provided by Virtualenv ensures you aren't depending on libraries on your dev box that aren't installed in production, and upgrading libraries won't break other applications

You can even create virtual environments with different versions of the python interpreter using:
virtualenv -p python2.6 2.6ENV

So, once you have a virtualenv, activate it and install yolk to give you a picture of what is inside the environment.
source .testenv/bin/activate
~> pip install yolk
~> yolk -l
Python          - 2.6.4        - active development (/usr/lib/python2.6/lib-dynload)
distribute      - 0.6.14       - active
pip             - 0.8.1        - active
wsgiref         - 0.1.2        - active development (/usr/lib/python2.6)
yolk            - 0.4.1        - active

Then go ahead and install the other packages you need:

pip install django

You can also build a requirements file to install exactly the same versions somewhere else:
pip freeze -E .testenv > requirements.txt

The holy trinity is apparently pip, virtualenv and fabric. Fabric is something I'll have to play with soon. There is a good tutorial on pip and virtualenv here, and using them with django here.

The only limitation/problem I have run into is that you can't move the virtual environment once it is created. There is a "--relocatable" directive to address this, but the webpage says that it is somewhat experimental at the moment.

Syntax highlighting code in Blogger

Posting code in Blogger by default results in something that is inexcusably ugly.  How can you make code posted in blogger look pretty?  For me, syntax highlighting and scrollable text boxes are a must.

The solution is: google-code-prettify, which does the highlighting for code.google.com (you could also consider SyntaxHighlighter).  Now the next problem is, how do you distribute the javascript and CSS for prettify?  Unfortunately Google doesn't make it available via their CDN like they do for other libraries like jQuery.  This would obviously be the best option for users since:
  • it would negate the need for additional hosting; and 
  • minimise load time since browsers could cache the code across many sites, and if needed download it from the closest CDN node.
So the remaining options are to slap it into your blogger template, host it yourself somewhere (like Google pages), use the subversion browse code link (ick), or figure out what code.google.com does, since it uses the same code. 

I opted for the last option, which works a treat.  Put this in your blogger template, right after the <head> tag:

<link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/3799605220899551948/css/ph_core.css">
 
<link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/3799605220899551948/css/ph_detail.css" >
 
<link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/3799605220899551948/css/d_sb_20080522.css" >

Then add an onload event to the body tag to call the PrettyPrint function:

<body onload="prettyPrint()" >

and, since the prettyprint CSS doesn't give you a scrolling box by default (!?), add this to the CSS in your template to avoid your code being chopped off:

/* Override prettyprint CSS, which doesn't allow scrolling box */
pre.prettyprint {
  overflow: auto;
}

Once you have done all that, you just need to wrap the code in your posts in:

<pre class="prettyprint">
</pre>

In summary, much harder than it needs to be. Blogger team, please build this functionality in!

Wednesday, January 19, 2011

List of DNS Providers

Just came across a list of DNS providers I made a while ago, and thought I'd post it here. They all seem to still be in business.  The top three I have heard good reports about:
  1. DNS Made Easy
  2. changeip.com 
  3. zoneedit.com
  4. bur.st (non-profit based in Perth)
  5. dnspark.com
  6. xname.org

    GPG HOWTO

    Here is a good, quick intro to using GPG, including generating and publishing keys, encrypting and signing.