Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Thursday, March 02, 2017

Proxy PAC file for work

Untitled

Proxy pac file to switch proxy based on whether I’m connected to OpenVPN or not.

Basically, OpenVPN IP is 10.8.0.6 and at home I have 192.168.1.xxx - so if either of those two are available, then I bypass proxy.

function FindProxyForURL(url, host)
{
    // firefox - Ctrl-Shift-J Chrome/Chromium: chrome://net-internals/#events
    var debug = true;
    var log = function() {
        if (debug) {
            var args = Array.prototype.slice.call(arguments);
            alert(args.join(" "));
        }
    }
    var bypassProxy = false;
    log("Checking for availability of myIpAddressEx:", typeof(myIpAddressEx) == "function");
    // firefox doesn't have myIpAddressEx - but it does seem to return the
    // right IP
    if (typeof(myIpAddressEx) != "function") {
        log("myIpAddress returns: ", myIpAddress());
        bypassProxy = myIpAddress() == '10.8.0.6' || myIpAddress().startsWith("192.168.1.");
    } else {
        // chromium seems to pick the first IP - in my case, a virtualbox HOST
        // only IP. So check in all IPs returned by myIpAddressEx
        var ips = myIpAddressEx().split(";");
        log("myIpAddressEx returns", myIpAddressEx());
        for(i=0; i< ips.length; i++) {
            if (ips[i] == "10.8.0.6" || ips[i].startsWith("192.168.1.")) {
                bypassProxy = true;
                break;
            }
        }
    }
    log("Can bypass proxy: ", bypassProxy);
    if (bypassProxy)
    {
        log ("DIRECT")
        return "DIRECT";
    }
    else
    {
        log( "PROXY")
        return "PROXY 10.98.2.8:8080";
    }
}

Put it someplace and in IE configure it with a file:// url

I really, really hate our proxy configuration at work!

Also, proxy pac file support is really arcane…​ however, it does work without additional configuration/addons - so there’s that.

Monday, February 20, 2017

Neovim on Windows

Untitled

If you’re a fan of Vim, then no doubt you’ve heard of Neovim - in fact, neovim has been a key driver in much of the changes that have made it into the latest version of vim (async, job control etc).

Neovim works extremely well as a daily driver on Linux - but for Windows support has been lagging. I’ve been using a fork from contributor equalsraf who’s been behind a lot of the windows support.

Last week, the main neovim project gained windows CI builds on appveyor. The instructions for installation were also updated on the wiki - so obviously, I was quick to try it. The windows appveyor builds also bundle the frontend - neovim-qt - however, there seems to be an issue that not all of neovim-qt runtime files are being included correctly in the build. Due to this, one cannot set GuiFont and so on and this is a bummer. Anyway, it’s easy to fix - just get the [neovim-qt binaries] from equalsraf’s appveyor and unzip them over. upating neovim

Since neovim is now on master and changes are coming in fast and thick, I wrote a little powershell to update my neovim installation. Here it goes for your enjoyment (you need powershell v5 for this)

UPDATE - 2017-03-01 - The bug in question https://github.com/neovim/neovim/issues/6145 is now fixed in Neovim windows builds. So in the script below you can leave out pulling down neovim-qt separately

param (
    [string] $loc="d:\utils\"
      )
wget "https://ci.appveyor.com/api/projects/neovim/neovim/artifacts/build/Neovim.zip?branch=master&job=Configuration%3A%20MINGW_64" `
    -OutFile "$env:TEMP\neovim.zip"
wget "https://ci.appveyor.com/api/projects/equalsraf/neovim-qt/artifacts/neovim-qt.zip?branch=master&job=Environment%3A%20SCRIPT%3Dcontrib%5Cappveyor-msvc.bat" `
    -OutFile "$env:TEMP\neovim-qt.zip"

expand-archive -Path "$env:TEMP\neovim.zip" -DestinationPath $loc -Force
expand-archive -Path "$env:TEMP\neovim-qt.zip" -DestinationPath "$loc\neovim" -Force