09.26.06

Wrong proxy settings? Write your own .pac!

Posted in web dev, programming, mac/os x at 3:32 pm by Clinton

Moving between home and work, I sometimes have issues with the proxy settings of my web browsers.

Today, I was trying out Eclipse, and while looking at the “what-new” and other tutorial related into, I had problems. The proxy.pac file that work has was making requests for 127.0.0.1 (aka “localhost”) also go through the proxy. Now, 1) I think that’s the wrong setting - if I ask for localhost it should go straight back to me - not to the local proxy and (then be ignored). 2) yes, I could set up the manual proxy settings with the appropriate “ignore proxy for” … addresses, but… i’m a coder at heart, so what I could I do?

Write my own (local) .pac file, and tell my browser to use that of course! :)

// Clinton’s custom proxy files - works at home and at work.
// Change the work vars to suit your home/school/work needs
// If you have multiple proxy setups at home, double-up the proxy behaviour.
function FindProxyForURL(url, host)
{
    var work_ip = “136.186.0.0″;
    var work_ip_mask = “255.255.0.0″;
    var work_proxy = “PROXY 136.186.1.14:8000; DIRECT”;

    // If only hostname specified, local host so go direct
    if (isPlainHostName(host))
        return “DIRECT”;
 
    // local host is always direct 
    if(isInNet(dnsResolve(host), “127.0.0.1″,“255.255.255.255″))
        return “DIRECT”;

    // Am I at work? Check for my IP in the work ip range
    if (isInNet(myIpAddress(),work_ip,work_ip_mask))
    {
        // Connect directly to local work domains
        if (isInNet(dnsResolve(host), work_ip, work_ip_mask))
            return “DIRECT”;
 
        // Is this a protocol that needs to be sent to the proxy?
        var bits = url.split(‘:’,2); // set limit - only need 2
        var p = (bits.length==2) ? bits[0] : ‘’;
        if (p ==‘http’ || p == ‘https’ || p == ‘ftp’ || p == ‘gopher’)
            return work_proxy;
    }

    // if you get to here, you don’t get a proxy
    return “DIRECT”;
}

It’s a quick hack, it works (so far) for me, and ymmv, but if you find it useful as well, that would great. This technique could be (and has been) extended to support ‘ad’ filtering from known URLs as well. There is a shExpMatch(url, “http://ads.somedomain.com/*”) function - I was hoping for regex powers, but alas it just supports “shell expressions” and that ain’t half as fun. :)

Helpful links on PAC files:
* http://en.wikipedia.org/wiki/Proxy_auto-config
* http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html
* Firebug http://www.joehewitt.com/software/firebug/ - yes it will tell you about errors in the pac file as well - v.cool.

09.08.06

Delphi Links

Posted in programming at 11:49 am by Clinton

Been a while since I tapped away at Delphi code (object pascal the Borland/Imprise variety:) but I was tweaking some older programs recently and wanting to note a couple of resource, … for myself if noone else :)

http://www.delphibasics.co.uk/ a great online reference…
http://www.delphiforfun.org/ Lots of cute programs and help for starters
http://www.marcocantu.com/ Writer of the infamouse “Mastering Delphi #” series of books (some good online freebies too).

Is Delphi going to die? …

06.07.06

blogroll. Hmm, upgrades…

Posted in web dev, byteclub, programming at 12:30 am by Clinton

Look again… more changes, feedback welcome (positive/negative/observational)…

http://www.byteclub.net/blog/index_comments.php

I haven’t linked in and checked the external blog comment feeds - i’m working on it and get it happening i promise.
Still think the count of post/comments is too high? Let me know your opinions.
Would really like to be able to sort comments by “post” (thread)? Let me know (pretty easy to do now).
Runs like a dog? Probably cache issues (but i did have to restart apache tonight… dunno what the deal is).

All feeds (blogs or comments) are cached for 10 mins, but I think there may be other proxy+chache issues causing havoc… it would be great to see things quicker!

04.25.06

Programmers & Stats - lethal!

Posted in learn, byteclub, programming at 9:51 pm by Clinton

“Programmers need to learn statistics or I will kill them all”
(catchy title - i remembered it :)

http://www.zedshaw.com/blog/programming/programmer_stats.html

From the author…

I have a major pet peeve that I need to confess. I go insane when I hear programmers talking about statistics like they know shit when it’s clearly obvious they do not. I’ve been studying it for years and years and still don’t think I know anything. This article is my call for all programmers to finally learn enough about statistics to at least know they don’t know shit. I have no idea why, but their confidence in their lacking knowledge is only surpassed by their lack of confidence in their personal appearance.

There’s also a bunch of other writtings there that I think may interests to other byteclubbers.