Author Archive

Mac OS X ‘open’ command

If you work with the command line often, you may find the open command useful.

open will launch the program associated with a file, as determined by LaunchServices. For example, to open all .c files in the current directory:

open *.c

It can also be used to open Finder to a particular directory. For example, to open Finder to the current directory:

open .

Using Mac OS X with Linux CUPS server

If you have a printer connected to a Linux box that is being shared via CUPS, the following command at the command line in Mac OS X will tell CUPS on your Mac to look for printers on other CUPS servers.

cupsctl BrowseProtocols='"cups dnssd"'

Now when you go to Printers in System Preferences, your shared Linux printer should show up automagically.

Using ‘find’ to quickly change file permissions

To quickly change UNIX/Linux file permissions (this applies to Mac OS X also), one can use the find command, combined with the -exec flag.

For example, suppose you want all directories nested beneath (and including) the current directory to have 755 permissions:

find . -type d -exec chmod 755 ‘{}’ \;

Explanation: ‘.’ refers to the current directory, ‘-type d’ indicates file type of directory, the command executed is chmod 755, where ‘{}’ is a cookie — the directory name will be inserted here. The exec command ends with a semicolon ‘;’, which must be escaped with a backslash so that your shell doesn’t interpret it.

To change file permissions to 644 (leaving the directories as is):

find . -type r -exec chmod 644 ‘{}’ \;

Note the type of ‘r’ to indicate a regular file.

Using these two find commands together, one can quickly change permissions on directories and files to 755 and 644 respectively to make them globally accessible, or 700 and 600 respectively to secure the files.

Makefile with Multiple Targets

# Sample simple Makefile for multiple targets (exec1, exec2)

all : exec1 exec2

exec1 : exec1.cpp
       g++ -ansi -Wall -f -o exec1 exec1.cpp

exec2 : exec2.cpp
       g++ -ansi -Wall -f -o exec2 exec2.cpp

clean :
       rm -f exec1 exec2

OpenOffice: Set Default Margins

Tired of Open Office giving you .8″ margins, when you expect the usual 1″? Here’s how to set up a template so that new documents will have your preferred margins set by default.

Create a New Document
Go to Format -> Page to set up your margins as you’d like them
Go to File -> Templates -> Save
Save as My Templates -> Default (or whatever name you’d prefer)
Now go to File -> Templates -> Organize
Select your template file (ie, My Templates -> Default)
Commands -> Set as Default Template.

Now when you create a new document, your margins should be set to your preferences already.

Windows 7 Printer Share with Mac OS X

Naturally, Windows 7 (Pro, at least) doesn’t play nicely on a Mac OS X network environment out of the box.  As far as I can tell, Windows 7 doesn’t utilize IPP, which Linux and Mac employ for printer sharing.

The situation: I wanted to print from my Mac laptop to my printer connected to Windows 7. To do this, I had to enable a feature disabled by default.

In Control Panel, have a look at Programs and Features. Then look under Turn Windows features on or off. Under Print and Document Services, check LPD Print Service to install and turn on this service, which will allow sharing your Windows 7 attached printer across your network.

Additionally, you need to specify to Windows the printer(s) you would like to share.  From the Start menu or Control Panel, select Devices and Printers. Right-click on the printer and select Printer Properties.  Under Sharing, select Share this printer and give it a share name without spaces.

On your Mac (the client), go to System Preferences then Print & Fax. Click the + to add a new printer. Under Advanced, set the Type as LPD/LPR printer. For the URL, enter lpd://ip_address/share_name/

For example, lpd://192.168.1.1/laserjet/

You may try using your machine’s name instead, but I had better luck using my IP address. If your IP address is dynamic and changes, this would obviously cause a problem. Select the correct driver based on your printer model, and give it a go!

Urban Terror GLW_StartOpenGL() Error Windows

So you just installed a fresh copy of the free multiplayer FPS game Urban Terror on Windows 7 (or possibly an earlier version).  The problem is, you keep getting a “GLW_StartOpenGL() – could not load OpenGL subsystem” error when you try to launch it.  You’re so close to fragging someone, yet so far.  If your video drivers are up to date, then herein lies the solution:

The game’s default full-screen resolution doesn’t match a native resolution of your hardware.  If you launch UT in windowed mode, you can then access the setup menu to select the correct video resolution.

To accomplish this:

1. Go to the install directory (probably “/Program Files/UrbanTerror” or “/Program Files (x86)/UrbanTerror”)

2. Inside here, go into the q3ut4 directory

3. Open the file q3config.cfg in your favorite text editor.  Keep in mind you may need to use Administrator permissions to modify the file.

4. Find r_fullscreen and change its value to 0 (zero).  Save and exit.

5. Lauch UT and access Setup->System.  Set your video mode.  This may involve choosing Custom and entering your video width & height.

6. Set Fullscreen to YesApply settings.

While this worked for me, your mileage may vary.

How to reinstall grub bootloader on Ubuntu 10.04 after Windows effs up your MBR

Windows decided to overwrite my MBR and clobber grub. I was successful at restoring grub by taking the following actions. While this may be a self-serving reminder for the next time it happens, others may find it useful.

It’s worth noting that grub2, which ships with Ubuntu 10.04, has made some changes — mostly notably, /boot/grub/menu.lst has been replaced with /boot/grub/grub.cfg. Following restoration instructions for previous versions of grub will likely fail.

1. Boot from Ubuntu Live CD (Install disc)

2. Open terminal

3. Look at partitions to get device name

sudo fdisk -l

4. If your Linux partition is not marked as bootable, go to System->Administration->Disk Utility and mark the partition as bootable.

5. Create a mount point

sudo mkdir /mnt/linux

6. Mount the partition by device name found in step 3 (for example, /dev/sda1)

sudo mount /dev/sdXY /mnt/linux

7. Run grub-install, which will rewrite the MBR. Note that here you want to specify the device (ie, hard disk) but not the partition. So for /dev/sda1, you’d use /dev/sda.

sudo grub-install --root-directory=/mnt/linux/ /dev/sdX

8. Reboot and grub should load. You may wish to run sudo update-grub after rebooting to update /boot/grub/grub.cfg with any partition or OS changes.

 
References:
https://help.ubuntu.com/community/Grub2#Reinstalling from LiveCD

Google Buzz Blows! (and how to turn it off)

I just wanted to say thank you to Google for sharing my private contacts with my other contacts. I appreciate you turning my private email account into a Twitter, err, Gwitter account without warning.

Smooth move.

After years of using Gmail, I’m considering going elsewhere. Only problem… Hotmail and Yahoo append advertisements to the end of outgoing emails, and that’s just as unacceptable!

Don’t get out your torches and pitchforks. Let’s just turn Buzz off and forget the whole thing happened.

The link to disable Buzz is hiding down at the very bottom of your Gmail inbox in small, unnoticeable font (bolded for your pleasure):

Gmail view: standard | turn off chat | turn off buzz | older version | basic HTML Learn more

Comcast DNS Problems

After a recent relocation, I re-signed up for Comcast and was pleasantly surprised to find my broadband speeds have increased!  Whether this is a new HSI product, or a function of my new location, I’m not sure, but I now seem to be sporting about 23 megabits down and 2.5 megabits up, which equates to over 2 megabytes per second streaming!  (Yeah, hella fast—for America anyway!)

Comcast Speed Test

The last couple of days, the service has been rather slow… but not in download speed.  When going to a webpage, the initial lookup took 2-6 seconds!  6 seconds is a long time to wait for your webpage to start loading!  In doing some tests, initially with nslookup and dig, and by timing requests to Comcast’s DNS servers, it was clear that the problem was Comcast’s DNS  servers.  Many packets were being dropped, but only to their DNS servers.  Since the queries are UDP packets, there is no “guarantee” that they will make it to their destination, so ostensibly much of the delay was in client-side time-outs and re-querying.

While some forums suggested OpenDNS as a solution, I went about using Level3′s DNS servers (pick two from 4.2.2.1 through 4.2.2.6) simply by entering the IP addresses into my router config.  Big improvement—pages now pop right up without delay!

This comes two days after being surprised by Comcast’s DNS hijacking redirection, which sends users to a page full of adverts, rather than returning an error, should they mistype a URL.  This [dis]service, dubbed “DNS Helper” by their marketing department, requires its users to opt-out, which I was able to do.  Sign into Comcast’s Customer Central and you should find the option in there, somewhere.  Or better yet, use someone else’s DNS, which is perhaps their master plan for scaling DNS.

So what is going on with Comcast?  Googling the problem reveals a history of complaints, so clearly their new redirection “service” isn’t to be blamed.  Slow DNS queries are a bottleneck for web surfing, yet don’t show up on “speed tests,” which may be why Comcast is happily ignoring this problem.

For now, I’ll just enjoy the fast connection without Comcast’s DNS until the billing department starts f—ing with me in about 12 months when my “deal” runs out!