Entries classified under tools


The BuildBot
- Let's build an open / distributed build network.
To links coding python tools web ... on Fri 07/08/05 at 02:21 PM
Google command line
- could be useful...
To links web cool tools google ... on Sun 06/26/05 at 07:40 PM
DarwinPorts Guide
- Alright, it looks like I'm going to have to break down and learn how to package ports since none of this crap is working on Tiger.
To links osx unix apple bsd tools ... on Wed 06/15/05 at 06:15 PM
The Apple Blog - Quicksilver Changes Everything
- Seriously.
YubNub
- This *does* look cool.
To links cool tools web social ... on Tue 06/07/05 at 06:40 PM

OS X Network Location support from the command line

I move between three different network configurations with my powerbook in an average day. Two of these configurations have proxy servers and one does not. Mac OS X has really excellent network location support that lets me configure this stuff once so that switching locations is as simple as invoking QuickSilver, typing the first few letters of the network location and BAM.

Most applications automatically pick up the new proxy configuration but some do not, like Firefox (which is one of three big reasons I still use Safari). I do a lot of work from the command line with network based tools such as curl, wget, port, http_ping, links, svn, etc. None of these use the system proxy settings but most support specifying a proxy server via the http_proxy environment variable.

I've searched high and low for a mechanism that would handle setting the http_proxy variable based on my current network location but have come up with nothing.

First, you need to create a file /etc/http_proxy that specifies the proxy servers for each Network Location you have setup in your Network Preferences (If anyone can figure out how to get the proxy information directly please let me know. I can get the current network location but not information about it). The file might look something like this:

Work = http://proxy.example.com:80
Library = http://proxy.library.com:80

The keys are the names of your network locations and the values are in http://proxy-host:proxy-port form.

Next, you'll need to put the following script somewhere along your $PATH named proxy-config and give it a chmod +x too.

 #!/bin/bash 

 # source this into your current to have the proxy 
 # environment variables needed by many command line 
 # apps setup correctly.

 # get the current network location name
 netloc=$(/usr/sbin/scselect 2>&1 | egrep '^ * ' | \
          sed 's:.*((.*)):\1:')

 # find the proxy in /etc/http_proxy based on the 
 # current location
 http_proxy=$(egrep "$netloc[ \t]*=" /etc/http_proxy | \
              sed 's/.*=[ \t]*(.*)/\1/')

 if [ -n "$http_proxy" ]; then
   export http_proxy
   export HTTP_PROXY="$http_proxy"
 else
   unset http_proxy
   unset HTTP_PROXY
 fi

 # the rest of this is used for symlink commands
 bn=$(basename $0)
 if [ "$bn" != "proxy-config" ]; then
     dn=$(cd $(dirname $0); pwd)
     for p in $(echo $PATH | sed 's/:/ /g'); do
       [ "$p" != "$dn" ] && [ -x "$p/$bn" ] && exec "$p/$bn" "$@"
     done
 fi

This script has two usage scenarios. You can source this into your current shell to have the http_proxy set correctly based on your current network location:

$ . proxy-config
$ echo $http_proxy
http://proxy.example.com:80

Alternatively, you can create symlinks to the proxy-config script using the names of commands that require http_proxy and the script will automatically set the variable and exec the real command.

Got that? No? Okay, let's move on.

Pretend you have /usr/bin/curl and you put the script from above at /usr/local/bin/proxy-config. You can get curl to use the approriate proxy settings by doing something like this:

# mkdir /usr/local/proxybin
# cd /usr/local/proxybin
# ln -s ../bin/proxy-config curl
# ls -l
total 4
lrwxr-xr-x  1 root wheel 19 May 11 13:30 curl -> ../bin/proxy-config

As long as /usr/local/proxybin is on your $PATH before /usr/bin, executing curl will actuall call proxy-config. proxy-config will then setup the proxy settings and exec /usr/bin/curl.

Now just create a symlink just like the one made for curl for anything else that requires proxy settings and enjoy network location support from the command line.

To weblog osx tools bash unix ... on Wed 05/11/05 at 05:50 PM

Typo - Weblog package atop Rails
- I'm going to see about moving my weblog to this..
Cell Phone Finder - A Whole New Way to Look at Cell Phones
- Right on.
To links web tools cell ... on Tue 05/03/05 at 08:24 PM
Design by Wiki
- This is too cool.
To links wiki tools architecture ... on Thu 04/28/05 at 06:09 PM
Using Bash's History Effectively
- Need to move away from `history | grep -i`
To links bash tools unix linux reference ... on Thu 04/07/05 at 04:14 PM
How to enable Emacs Keybindings w/ Firefox (Linux, Mac, Windows)
- One down, two to go...
To links moz web tools tips ... on Wed 04/06/05 at 08:04 PM
Starbucks Delocator
- Find locally owned alternatives to Starbucks in your neighborhood.
To links diversions tools ... on Tue 04/05/05 at 01:03 PM
Emacs as Cargo
- Came across this odd section in a "leaving Emacs for vi" document and it has a really interesting description of the history of FSF/GNU, Linux, and the evolution of Free Software. Seems out of place in this document but is worth reading.
Conkeror - Emacs mode for Firefox
- Make firefox act like Emacs. How cool is that?
To links tools web moz ... on Sun 03/27/05 at 06:42 PM
First Video Game Written In Ant
- For christ sakes, man! I hope Hani doesn't ever see this...
To links coding java funny tools ... on Sat 02/26/05 at 05:40 AM
Emacs WebDev Environment
- Information on setting up emacs for (X)HTML web development including nxml-mode, rng-validate-mode, etc.
To links emacs tools coding web design ... on Tue 02/22/05 at 06:26 PM
How I learned to stop worrying and love the command line, part 1.
- Introduction to being a complete bad-ass.
To links coding linux unix tools ... on Fri 02/18/05 at 03:10 AM
Markdown in Python
- An implementation of John Gruber's markdown text to XHTML processor in Python.
To links coding python blogging tools web ... on Wed 02/16/05 at 09:33 PM
del.icio.us/popular/sparkline
- del.icio.us/popular with nifty sparkline graphs for tracking popularity over time (via Simon Willison)
To links delicious tools web ... on Mon 02/14/05 at 05:04 AM
Vonage Third Party Call Control
- Vonage hacking..
To links coding reference tools rest ... on Sat 02/12/05 at 05:23 AM
The Unassociated Press
- New York Times covers the Wikinews project.
To links journalism web wiki civic tools ... on Fri 02/11/05 at 04:50 AM
TheyWorkForYou.com
- Track whether your MP is working for you in the UK Parliament.. Really cool looking piece of civic software.
To links civic tools web politics ... on Mon 02/07/05 at 03:35 AM
Subversion quick start
- Quick guide to loading a new project into subversion.
New York Times Link Generator
- Generates non-expiring links to New York Times content. Bookmarklet included.
To links tools web blogging ... on Tue 02/01/05 at 02:10 PM
Subversion for CVS Users
- Title says it all..
My Experiences With Subversion
- Nice look at moving to subversion. Go into migrating from CVS, subversion idioms, gotchas, etc.
Version Control with Subversion
- Entire subversion book on one page.
To links coding reference tools ... on Sun 01/30/05 at 08:52 AM
Eclipse Java-GNOME Demo
- Demo of 100% free Java/Eclipse natively compiled with gcj. This is slated for Fedora Core 4.
To links java linux foss tools ... on Wed 01/26/05 at 08:29 PM
Picasa
- Photo management software, free from Google. Find, edit, share photos.
To links google cool diversions tools web ... on Tue 01/18/05 at 01:11 PM

Experimental del.icio.us Posting Interface Thing Generator

Joshua has been toying with a new posting interface for del.icio.us. It is based on nutr.itio.us, the nice third party posting interface that has been MIA for a while. The new interface provides your tag list, a list of popular tags for the page you're bookmarking, your full tag list, and some popular tags in general. It isn't finished yet but it's an improvement over the current no-frills posting interface.

UPDATE: Make sure you understand that this is not finished yet and could flake out on you at any time as Joshua is enhancing it. Also, you have to scroll down a bit to see the new bits of functionality.

ANOTHER UPDATE: By popular request, a Big Thing has been added that makes more of the new posting interface visible without scrolling.

You can get a Thing for the new interface by entering your username below. After generating the Thing, drag it to your bookmarks bar. I've tested this on Firefox 1.0 and Safari.

If nothing pops up down here than you probably don't deserve it. :)
To weblog delicious tools ... on Wed 01/12/05 at 01:44 PM