Skip to main content

Posts

Showing posts with the label linux

Secure Synergy Configuration for HTPC Control

I've been experimenting with different configurations for controlling my HTPC. Since I typically have my laptop on the couch with me, one setup I'm trying is Synergy. By itself, Synergy is completely insecure. However, it's easy enough to secure through the use of SSH tunnels. There are lots of tutorials for setting up Synergy through a tunnel, but I didn't find any that suit the HTPC use case I have. To use it with an HTPC, the Synergy server needs to be running on the laptop since that's where the keyboard and mouse is that you'd like to share across various computers. Typically tutorials will have you create tunnels from the Synergy client computers to the Synergy server computer where sshd is also running. Since my Synergy server is a laptop, I don't want to run sshd on it. Instead, I have sshd running on my HTPC. To make that work, you need a reverse SSH tunnel: ssh -f -R 24800:localhost:24800 htpc Instead of forwarding connections from my laptop...
Read more

My 5 Rules for Writing Bash Scripts

Don't use Bash. Put quotes around all variables:  echo "$FOO" Don't use Bash. Put spaces between everything except assignments:  FOO="bar"; if [[ -n "$FOO" ]]; then echo "$FOO"; fi Don't use Bash.
Read more

Reencode Videos to Play Faster

I'm currently recording screencasts (using XVidCap ) to use as a video-based help system in ASE . Because the Android emulator is slow and the steps are quite simple to follow, it's useful to speed up the playback of the screencast. I'm currently doing this with MEncoder (the magic flag is -speed <multiplier> ): mencoder input.mpg -ovc lavc -lavcopts vcodec=mpeg4 -speed 2 -oac copy -o output.avi I also recommend Avidemux (over Open Movie Editor) for your basic editing needs.
Read more

Logitech Pan/Tilt Python C Extension

I just started learning C++ in earnest about a month ago. This weekend I felt like I knew enough to start looking at Python C extensions, so I wrote one to control the pan and tilt functions of my Logitech Orbit . I used this camera previously for my OLPC telepresence project. There's already a similar module out there, called lpantilt , that does this using Cython . But, I wanted to take a crack at it myself and do it with straight C. #include <Python.h> #include <errno.h> #include <sys/ioctl.h> #include <fcntl.h> #include "linux/videodev2.h" #include "uvcvideo.h" static int pantilt(int pan, int tilt, int reset) { struct v4l2_ext_control xctrls[2]; struct v4l2_ext_controls ctrls; if (reset) { xctrls[0].id = V4L2_CID_PAN_RESET; xctrls[0].value = 1; xctrls[1].id = V4L2_CID_TILT_RESET; xctrls[1].value = 1; } else { xctrls[0].id = V4L2_CID_PAN_RELATIVE; xctrls[0].value = pan; xctrls[1].id = V4L2_CID_TILT_RELATIVE; ...
Read more

Ubuntu Jaunty Wireless and RT61PCI

I upgraded to Jaunty yesterday and again had to struggle with my wireless. This time, it wasn't necessary to install a new kernel module. Instead, I just needed to remove Network Manager and set up wpa_supplicant . Here's my new /etc/network/interfaces that I configured for my WPA2 PSK AES TLA network. auto wlan0 iface wlan0 inet dhcp wpa-driver wext wpa-conf managed wpa-ssid myssid wpa-ap-scan 1 wpa-proto RSN wpa-pairwise CCMP wpa-group CCMP wpa-key-mgmt WPA-PSK wpa-psk mypsk With that, all I needed to do was sudo /etc/init.d/networking restart .
Read more

Streaming Music to the Chumby with PulseAudio and GStreamer

I spent a little while today figuring out how to stream the music I was playing in Rhythmbox (in the living room) to my Chumby (in the kitchen) . I found a nice article that explains how to set up a GStreamer pipeline for streaming the monitor output from PulseAudio through Icecast . It works quite well for streaming to the Chumby (except for a pretty significant lag). Here's the quick start guide for Ubuntu Intrepid: Set up PulseAudio . $ sudo apt-get install icecast2 Edit /etc/default/icecast2 to enable Icecast and /etc/icecast2/icecast.xml to set a password (defaults to "hackme"). $ sudo /etc/init.d/icecast2 start Find the name of your PulseAudio monitor device by opening the manager from the PulseAudio applet. It should start with alsa_output.pci and end with monitor . $ gst-launch pulsesrc device=<alsa_output.pci...monitor> ! audioconvert ! vorbisenc ! oggmux ! shout2send mount=/stream.ogg port=8000 password=hackme ip=127.0.0.1 Start sshd on your Chumb...
Read more

How to Run Rise of Nations with Wine

I spent quite a while last night getting Rise of Nations Golden Edition running on Ubuntu Ibex. Here's what it took: Part 1: Make CD images using Cdrdao Cdrdao is used for dumping images of CDs in .bin/.toc format. Normally dd is enough to make an image. But, for copy-protected discs like RoN, you need something a little stronger. Here's the command I used to make images of both discs: $ cdrdao read-cd --read-raw --datafile image.bin \ --device /dev/cdrw2 --driver generic-mmc-raw image.toc Be sure to replace /dev/cdrw2 with your CDROM device. Part 2: Mount the images using CDemu Windows users are probably familiar with DAEMON Tools. CDemu is the equivalent for Linux. There are nice Debian packages available . Download and install, in order: vhba-dkms libmirage cdemu-daemon cdemu-client Mounting the images after installing CDemu is simple. $ cdemu load 0 image.toc Part 3: Update and configure Wine The standard Ubuntu repositories do not have the most up-to-date version of Wine...
Read more

How to Combine AVIs in Ubuntu

Here's a tiny bash function I wrote to do it with mencoder ( sudo apt-get install mencoder ): function combineavis() { read -p "Combined AVI name: " -e output mencoder "$@" -o "$output" -ovc copy -oac copy } I also found this page (which has quite a few handy snippets about lots of various Linux tasks). It recommends using avimerge -o "$output" -i "$@" instead.
Read more

Backing Up and Resizing Partitions in Linux

I just finished reorganizing my partition scheme and it was surprisingly painless. Originally, I had two 75GB, 10K Raptors. I installed Ubuntu on the first and Windows XP on the second. I was careful to keep the Windows drive pristine and use Grub to handle the dual booting. That way, I could always simply change my drive boot order in BIOS to boot into Windows if something happened to my Ubuntu drive or Grub. That was two years ago. In that time, I booted into Windows only once or twice. So, I decided to take better advantage of the other drive. The original setup was something like this: /dev/sda1 -> /boot /dev/sda2 -> swap /dev/sda3 -> / /dev/sda4 -> /home /dev/sdb1 -> Windows XP First, I backed up the Windows drive using dd just in case I wanted to recreate it sometime down the road. $ dd if=/dev/sdb1 | gzip -c | split -b 2000m - /media/backup/wxp.img.gz. Now it's easy to restore it later. $ cat /media/backup/wxp.img.gz.* | gzip -dc | dd of=/dev/sdb1 I also back...
Read more

SSH Tunnel to Router Settings

I always forget how to do this and it's extremely useful. If you have SSH access to your box behind your router, you can use a double SSH tunnel to connect to the router and adjust your settings. localhost$ ssh -L 8888:remotehost:8888 remotehost remotehost$ ssh -L 8888:router:443 localhost Now just point your localhost browser to https://localhost:8888/.
Read more

Awesome Linux Utilities for five hundred, Alex!

I just discovered 'rename' today after briefly considering writing it myself. Here's the gist of it: rename [ -v ] [ -n ] [ -f ] perlexpr [ files ] So, for example: rename 's/(.*?), (\w+)/$2 $1/' *.avi Changes a bunch of videos from "World Is Not Enough, The.avi" to "The World Is Not Enough.avi" Hooray!
Read more

Monitoring Hard Disks with SMART

I have quite a few hard disks running at all times. I came across this article this weekend and whipped up a little something to keep an eye on them. import subprocess import os disk_uuids = [entry.split()[0].split('=')[1] for entry in open('/etc/fstab') if entry.startswith('UUID=')] disk_devices = [] for uuid in disk_uuids: uuid_path = '/dev/disk/by-uuid/' + uuid try: dev = os.readlink(uuid_path) dev = os.path.join(os.path.dirname(uuid_path), dev) dev = os.path.abspath(dev) except OSError: print '%s does not exist.' % uuid_path continue disk_devices.append(dev) disk_health = {} for disk in disk_devices: p = subprocess.Popen(['smartctl', '-Hc', disk], stdout=subprocess.PIPE) for line in p.stdout.readlines(): if line.startswith('SMART overall-health self-assessment test result:'): health = line.split()[-1] disk_health[disk] = health break for disk, health ...
Read more

Whoopee! A blinking LED!

I just got my Arduino today and set up was pretty easy. My box is running Ubuntu Feisty. Download arudino-0009.tgz and extract it. Install avrdude, avr-libc, binutils-avr, gcc-avr, and uisp. Execute arduino-0009/arduino. Java was already set up in my case and I'm pretty sure not all of those avr related packages are necessary. But, it worked for me :) Update: I just discovered the Arduino Playground which has some nice articles on how to set up your Arduino on different platforms.
Read more

Where's my open source implicit SSL FTP clients?

I've been looking for a good, open source, linux, implicit SSL capable, FTP client. There don't seem to be very many. The best (and only) one I've found is FireFTP . Unfortunately, since FireFTP is a Firefox extension, I can't use it remotely over SSH :( Update I've since written some Python scripts using PycURL to do my dirty work. While PycURL is useful for searching through directories and such, I did find that actually executing cURL as a sub process to handle downloads is easier than doing so through the API.
Read more