Showing posts with label Utilities. Show all posts
Showing posts with label Utilities. 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.

Thursday, January 26, 2017

Syncthing - run your own sync server

What I'm after

I'm trying out syncthing - I've become frustrated that none of the other options seem to tick all the boxes of my needs. Here's what I need and it doesn't seem that I'm asking for a lot here:

  1. Bi directional file syncing
  2. Security & privacy - at rest and in motion
  3. Windows client
  4. Linux desktop client
  5. Android client.

The competitors

Here's what I've tried so far:

  1. Dropbox - fails on privacy
  2. Google Drive - no linux desktop client - so a non starter.
  3. OneDrive - ditto AFAIK
  4. Mega - Android client won't autosync changes.

And so I've been looking at setting up my own sync/cloud storage. I used to run BTSync but dropped it since it wasn't open source. Apparently, it's now renamed to 'Resilio'. I've also been interested in OwnCloud - but it seems an overkill - I don't need calendaring and such.

I've also heard good things about seafile as well - but that will have to wait for another day.

Syncthing - installation

So today being a holiday, thought of giving syncthing a try. It's basically an open source BTSync like application. It looked interesting and seemed to tick all my boxes so worth a try. However, installation wasn't as smooth - and getting it to work

  1. Linux Desktop- Deb packages are available; setup was a snap. Getting it configured and running as a systemd service took some going through the online manual
  2. Windows - Used SyncTrayzor. Getting it installed wasn't problematic.
  3. Android - there's a syncthing app on the play store. It works but seems a little crashy (clicking on the folder icon always crashes it.)
  4. Linux server - so I have a cloud vm and decided to have each of the machines above sync with it... so I can make changes anywhere and I can get it on the other devices. Once again, after I added the apt source, getting syncthing installed was a breeze.

Configuration

And now coming to configuration - this is where I feel Syncthing's UX will scare away most people (probably except those who're just running windows desktops). Here's my nits:

  1. Adding a remote machine - you need to provide a 50- 55 key machine Id. In my case, I needed to provide the key of my headless server to the local linux desktop service. This in itself wasn't a problem - I just picked the key from the logs on the server journalctl -e -u syncthing.service and pasted it. Thing is, that once you add a remote machine, you then get prompted on the web interface that a machine wants to share. On my headless server, I could see my desktop trying to connect (from logs) but it was waiting for authorization. I finally had to dig into syncthing's configuration syntax and edit ~/.config/syncthing/config.xml and add device id nodes for my desktop, windows machine and android phone and restart each time after editing the config.
  2. Syncthing's scheme is that not only does a remote machine have to be added, but you also have to specifically mark what folders are shared with each machine. This means that you have to configure each machine with folders with teh same id otherwise they won't sync. This caused some confusion - esp since the windows app decided to create a folder with a random id where as the linux just had default as the id. I finally just went with default everywhere.
  3. There's something called an introducer.. I read the description of what it's supposed to do and did not understand.. Better docs/graphic would help a lot here. For the moment though, I decided to stay away from it.

Anyway, after I sorted those out, it seems to be working... I tried editing files on Android and it got pushed to other nodes and vice-versa. It feels a little sluggish in detecting changes - but I can live with that.

I also need to understand it's n-way sync process... maybe I can go peer to peer. Syncthing definitely has a diamond in the rough feel to it and I'd rather support an open source project if it can job done (albeit with some initial pain getting it set up)

What can be done better

  1. Getting a headless central node working painlessly would go a long way. I expect a lot of people are using syncthing this way... something along the lines of :
    1. Get all your clients installed,
    2. install on headless syncbox;
    3. Provide a cli tool that will configure a device for the default folder. syncthing-cli add folder=<folder-id> <device-id1>, <deviceid2>... All this does is update your config & restart syncthing service. folder defaults to default if not specified.

It's open source - and given that I like what I see (for the most part), I'll probably try my hand at sending in a PR.

Happy syncing!

Thursday, July 31, 2014

Password utopia - finally!

Passwords - what a pain.

Bajillions of websites, different usernames, work projects and their environments and their passwords...how the hell are you supposed to keep track of all of it. And then a dozen different machines that you work on... and need access to your passwords

Each of us have their own mechanisms - plain text file 'hidden' some place to slightly more advanced ones. For the longest of times, I used to have a GPG encrypted text file sync'ed over my github repository. It was simple and did the job though used to be a little painful to get started off on a new machine (needed to have my gpg keys etc and git set up and so on.). Also, it didn't help in the password generation department

In between, I've played with other tools like pass - but then cross platform is a must and that didn't work. Purely command line is good but a pain to deal with.

So here's what my password-utopia looks like:

  1. passwords are automatically synced
  2. accessible anywhere - linux, windows, android and CLI interface
  3. Key secured if possible with GPG
  4. search over saved passwords
  5. Browser helpers to automatically fill in usernames/passwords
  6. Generate strong passwords

Keepass2 does all of the above - after initially dabbling with it, I've now moved all my passwords on to it. you can use Dropbox, Google drive or any other cloud sync tool to sync your passwords across machines. kpcli provides cli access and you have KeepassDroid on android. There's a mono version for Linux but I found that slow and clunky. KeepassX nightly ppa has support for kdbx database files and while a little lacking in features, it works much better for me on Linux.

Securing the Keepass2 database - you can use a password and a key file combination. You could also use your windows account but then I think cross platform compatibility is lost. anyway, random key file + strong master password is quite ample for my needs.

Saturday, January 30, 2010

A new tool for the toolbox!

Firstly - my VM setup:

I'm running Virtualbox with Xubuntu 9.10 on Win7 host - and its pretty. Its on a office standard issue Dell D531 - meaning they're AMD Turion X2 TL-60 and 2GB of RAM.

Now the Turion's supposed to have hw virtualization (AMD-V) however, the moment hw virtualization was enabled in virtualbox and I tried starting the vm, the machine would hard reboot!!!

After searching high and low, turns out that its an issue with Dell bioses and they dont have any updates. Here's a page that tracks the issue. Imagine my happiness when a couple of days ago, found that dell had released an unofficial bios update (T12).Well, its gone in, and things are running swimmingly well - my VM now has 2 procs, is stable and I hardly feel I'm in a VM :). In fact, this post is coming from the VM  - firefox with 12 tabs, a few terminals and emacs running on 600 MB of RAM.

Now let me come to the new tool I was talking about

I like to run the VM full screen - feels best that way. After trying out enough and more of multiple desktop softwares, have finally settled on VirtuaWin - beats the crap out of other tools, systray integration is great, has window rules and so on. Over the past couple of weeks, its come close to the ideal tool - does the job well and you hardly know its there :-)

Monday, June 23, 2008

Compact Ubuntu

I've always hated the fact that on Ubuntu with the default themes, there's far too much space wasted. The buttons are too tall, the treeview wastes too much space so that if you're on eclipse or some other ide, you see a precious few items on the screen.

I've been trying to tweak it to no end - even looking to see if there are any ~/.gtkrc-2.0 tweaks. Found a few links such as this Making Eclipse look good on Linux - Max's blog - however, didn't really satisfy my need.

And so it stayed until today when I came across Clearlooks Compact Gnome Theme.

I love it - one more for my list of must-haves!

Wednesday, June 18, 2008

Enjoy symlinks and hardlinks on NTFS

Can't believe I didnt come across this before - if you've gotten used taming your hdd by creating links to folders and have been annoyed with the lack of symlinks and hardlinks on NTFS, then despair no more. I've been using Mark Russinovich's (of sysinternals fame) tool - junction.exe all this while and though it works great, have always wanted something that would integrate with Explorer too. For an in-depth discussion - read http://shell-shocked.org/article.php?id=284 Anyways, I'm extremely happy with NTFS Link - this will surely go into my list of "Must have tools - install immediately on a new machine" list :-)

Thursday, June 12, 2008

VPN into Windows VPN Server from Ubuntu *Hardy* Intrepid

** Update 2008/11/17 **: Networkmanager is broken in intrepid. To get it  working had to install network manager from ppa as given here - http://www.ubuntu-forums.com/showpost.php?s=e0d93c09b8c340976477456593ac4cf7&p=6094870&postcount=5

Ok - this was easy - and while there's some resources on google, I had to figure out a few itty bitty things for my work VPN setup.

install

  • network-manager-pptp

  • pptp-linux


Restart network manager with

killall nm-applet
sudo /etc/init.d/dbus restart
nm-applet --sm-disable &


Configure VPN settings

Click on the network manager applet and click on VPN connections

  1. Create a new VPN connection

  2. Ensure that you select Refuse CHAP  in the authentication tab.

  3. In the routing tab, you can give netmasks that need to go through VPN - for my work network, I have: 10.10.5.0/24 172.16.106.0/24


That's it. Now click on the Network applet, and connect to your VPN. In the authentication dialog, use <domain>\username and your windows domain password.

Friday, March 28, 2008

Gnuplot, dstat - easy graphing on Linux

Recently, started fiddling around with how to monitor and graph performance data on linux boxes. Other than the usual tools like top and vmstat, which are either interactive (top) or too textual to do anything much.

First off, vmstat, doesnt lend itself well to graphing without additional scripts to lay out the data so tools like gnuplot can be used. Secondly, and more seriously, it doesn't include a timestamp in the output.

Looking around a bit found that dstat seems to be a good replacement to vmstat (and iostat) - and the generated data is consumable with gnuplot.

Here's a quick example of generating graphs for CPU user, system and idle times
dstat -tc 5 500 > dstat.raw

now fire up gnuplot and go ahead and plot it
gnuplot> set xdata time gnuplot> set timefmt "%s" gnuplot> set format x "%M:%S" gnuplot> plot "dstat.raw" using 1:2 title "User" with lines, "dstat.raw" using 1:3 title "Sys" with lines, "dstat.raw" using 1:4 title "Idle" using lines

To make gnuplot generat an output file, you need

gnuplot> set term png

gnuplot> set output "dstat.png"

gnuplot> replot

dstat png - User, system and Idle times

And you're done. here's the graph generated on my machine. There's loads more that you can do - and admittedly, you can do everything by dumping your file to excel. However, that doesn't lend itself well to a completely automated process. When you're doing performance testing and such like, you will likely repeat this enough number of times. Not having to do it manually helps big time!

Thursday, March 27, 2008

Working with huge XML files - tools of the trade.

XMLStarlet is great for slicing and dicing huge XML files. Had a run in recently - had a 80 Mb XML file in a single line :D. Guess what, most editors that I tried balked and fell over. This was on a 2Gig Core2 Duo machine.

XMLSpy, vi, emacs, notepad++ all died - and trying to do something with a 80 Gig XML where the 80 gigs are on a single line isnt much fun. So the first order of business was to pretty print the XML. XMLstarlet worked great -
xmlstarlet fo file.xml > output.xml

and you're done.

The next order of business was that we needed to validate the XML document against a schema. Our first attempt was with Sun's multi schema validator (MSV). MSV does not validate the whole document but instead stops after a certain number of failures. So, MSV - out, XMLStarlet in. XMLStarlet can validate documents again W3C schema, DTD  or a RELAXNG schema.
xmlstarlet val --err --xsd schema.xsd input.xml >  errors.txt

And presto! - you get an error report that you can slice and dice with sed/awk or anything else at all.

XMLStarlet also allows you to write Xpaths to query the xml - however, I found the syntax too weird and round about. A better alternative is a perl based solutions - XSH2 - a command line xml editing shell. You can install it under cygwin and it supports basic command pipelining and redirection.

So go ahead and launch XSH. At your cygwin prompt
[~]xsh
---------------------------------------
 xsh - XML Editing Shell version 2.1.1
---------------------------------------

Copyright (c) 2002 Petr Pajas.
This is free software, you may use it and distribute it under
either the GNU GPL Version 2, or under the Perl Artistic License.
Using terminal type: Term::ReadLine::Gnu
Hint: Type `help' or `help | less' to get more help.
$scratch/>

Now, lets load up our document, type
$scratch/>$x:=open formatted.xml

Your prompt changes to
$x/>

So go ahead and try a few xpaths
$x/> ls /path/to/node

and XSH prints out the matching nodes. Now what if you need to create a document fragment of nodes matching a certain xpath? Piece of cake - do ahead
$x/> ls /path/to/node | tee fragment.xml

XSH2 has many, many more features - but this should be good enough to get you off the ground.

Tuesday, July 03, 2007

Sluggish Firefox - and what a hog!

Okay - for the past few days I've been irritated with the browsing experience at home. Pages (google reader, Yahoo mail etc seemed inexplicably slower than before - but they'd load alright - just seemed that teeny weeny bit slower that's enough to leave you suspicious).

I first suspected my ISP (verizon) for frequent dropped connections (saw the DSL modem lights reset a couple of times a day), then my wifi modem (not a high end one), then spyware/malware. So after the usual barrage of tests - wifi interference sources/anti virus/anti spyware/cable tests etc, I still hadn't nailed it.

Finally, used procexp ( you can use plain 'ole Task manager too - this is just flashier) and saw that FF had 330 MB of RAM with 3 or 4 tabs. Also, just plain clicking on a text box was slow, typing into a text field would echo characters after a noticeable delay - so this was definitely a browser problem.

When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.


-- Sherlock Holmes


Ain't that an apt quote??? I love the addons I have and probably I have one too many. This page on problematic addons  was a life-saver - after disabling a bunch of infrequently used addons (stumble upon toolbar, google toolbar, browser sync, adblock filterset g, foxy tunes and some more), I'm back in browsing heaven. The only addons I have now enabled are




  • diigo toolbar

  • all in one gestures

  • Adblock

  • Flashgot

  • Piclens


What a relief!

BTW, addons are also the latest attack vector. So be wary of who you let into your browser!

Thursday, June 28, 2007

Piclens - full screen slideshows with flickr (and others)

discovered Piclens

Its a great addin for firefox - and integrates with Flickr to give you full screen slideshows a'la Picasa slideshows on your machine!! Its a bit tricky to figure out how to get it to work - Just hover any picture on any page  and click on the blue bubbly overlay button that appears

Saturday, March 17, 2007

Ninotech Path Copy 4

Ninotech Path Copy 4
Novell Cool Solutions: Cool Tool

Was looking for a shell extension to copy filenames from explorer. Thought there'd be a dime a dozen - and it turns out that
a) they have 20 other things that I dont want.
b) Its trial ware.

Finally after searching high and low, came across this and it's GREAT!


powered by performancing firefox

Sunday, February 25, 2007

Performancing and Wordpress - initial imression - very nice!


Performancing | Firefox Add-ons | Mozilla Corporation
Performancing for Firefox is a full featured blog editor that sits right in your Firefox browser and lets you post to your blog easily. You can drag and drop formatted text from the page you happen to be browsing, and take notes as well as post to your blog.


powered by performancing firefox

Saturday, February 24, 2007

Instant messenger client utopia

GAIM...

I hate running 3 different chat clients (yahoo, msn, gtalk) on my machine - and that's just 3x memory, startup programs and useless adversting too many.

And I hate msn and yahoo's advertising that's built into their clients...esp on MSN which insists on opening a mini page on login...

Use GAIM - and do yourself a favour. Of course that's if you don't need the very specialized features :)).

Installation is a breeze and use plugins you like and avoid the bloat....The best plugins I like are guifications and text replace. Lastly, if you keep moving between machines as much as I do, then its a breeze to retain your settings between all your machines.