Archive for the ‘ Computers ’ Category

Speed your web browsing WAY up with Squid3

I haven’t tried this in a long time, but I used to run Squid3 at home on my pfSense router box (older Pentium 4 — worked great) and I just had the idea to use it on my laptop to speed up web browsing. It makes a HUGE difference and now pages look like they’re using AJAX for requests since the images and headers and stuff just stay put when moving between pages. RAM cache is monumentally faster than disk cache, and we’re just totally disabling disk caching / log files with this squid3 config.

To set this up, you’ll need to install squid3, set your web browser to use 127.0.0.1 (sometimes the POSIX standard of just ’0′ isn’t supported because some developers make crappy software that isn’t really POSIX) port 3128 as a proxy for HTTP (you could cache HTTPS too but IMO it’s not worth it for just general browsing), paste the stuff below at the bottom of your squid3 config file (/etc/squid3/squid.conf on Ubuntu 11.04 for me) and restart squid3 (/etc/init.d/squid3 restart).

I left most of the stuff default, but I disabled the log files and set the RAM cache down to 128 MB. You can adjust as necessary.

Update: Put some comments in to help with getting this working in Squid v2.x, disk cache, and making it work on your local network :)

## root@helios:/etc/squid3# egrep -v '^#' squid.conf |tr -s '\n'

## uncomment next line if using squid 2
#acl all src 0.0.0.0/0.0.0.0

## example of how to let your whole local 192.168.1.0/24 network use the cache
#acl localnet src 192.168.1.0/24
#http_access allow manager localnet
#http_access allow localnet

acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl SSL_ports port 443
acl Safe_ports port 80		# http
acl Safe_ports port 21		# ftp
acl Safe_ports port 443		# https
acl Safe_ports port 70		# gopher
acl Safe_ports port 210		# wais
acl Safe_ports port 1025-65535	# unregistered ports
acl Safe_ports port 280		# http-mgmt
acl Safe_ports port 488		# gss-http
acl Safe_ports port 591		# filemaker
acl Safe_ports port 777		# multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access deny all
http_port 3128
hierarchy_stoplist cgi-bin ?
cache_mem 128 MB
maximum_object_size_in_memory 512 KB
memory_replacement_policy heap LFUDA
coredump_dir /var/spool/squid3
refresh_pattern ^ftp:		1440	20%	10080
refresh_pattern ^gopher:	1440	0%	1440
refresh_pattern -i (/cgi-bin/|\?) 0	0%	0
refresh_pattern .		0	20%	4320

## disk cache stuff if you want
#cache_replacement_policy heap LFUDA
#cache_dir aufs /var/spool/squid 4096 16 256
#minimum_object_size 0 KB
#maximum_object_size 4096 KB
#cache_swap_low 90
#cache_swap_high 95

## disable all logging for better performance
access_log none
cache_store_log none
cache_log /dev/null

Fun ASCII text decoration from the 90s

I couldn’t resist posting these because they’re great for drawing attention to stuff on internal wiki pages and documentation. Shamelessly ripped from http://www.xatworld.com/nicks/decorarnickxat.html

╚»★«╝ ( EMO NICK) ╚»★«╝
¨¨¨™¤¦¤™¨¨¨~*§*®§* ( YOUR XAT NICK HERE ) *§®*§*~¨¨¨™¤¦¤™¨¨¨
©~®§][©] ( YOUR XAT NICK HERE ) [©][§®~©
®~©~®][§] ( YOUR XAT NICK HERE ) [§][®~©~®
§®*§[•.*.•]™ ( YOUR XAT NICK HERE ) ™[•.*.•]§®*§
}{®~©}{*§*}{¤¦¤} ( YOUR XAT NICK HERE ) {*§*}{¤¦¤}{®~©}{
°¨¨¨™¤¦¤™¨¨¨° ( YOUR XAT NICK HERE ) °¨¨¨™¤¦¤™¨¨¨°
O~°’¨¤¦¤¨’°~O** ( YOUR XAT NICK HERE ) **O~°’¨¤¦¤¨’°~O
™©~®}- ( YOUR XAT NICK HERE ) -{©~®™
™`~*.*~`¤-_ ( YOUR XAT NICK HERE ) _-¤`~*.*~`™
™`•.¸¸.•¤¦¤`••._.• ] ( YOUR XAT NICK HERE ) [ `•.¸¸.•¤¦¤`••._.•`™
°¨¨¨™`•.•`¤¦¤ ( YOUR XAT NICK HERE ) ¤¦¤`•.•` ™¨¨¨°
¨'*•~-.¸¸,.-~* ] ( YOUR XAT NICK HERE ) [ ¨'*•~-.¸¸,.-~*'
o°°o°°o°*~.] ( YOUR XAT NICK HERE ) [.~* °o°°o°°o
(¯`•._.•[ ( YOUR XAT NICK HERE ) ]•._.•´¯)
×÷•.•´¯`•)» ( YOUR XAT NICK HERE ) «(•´¯`•.•÷×
,.-~*’¨¯¨’*•~-.¸-(_ ( YOUR XAT NICK HERE ) _)-,.-~*’¨¯¨’*•~-.¸
O?°’¨ ( YOUR XAT NICK HERE ) ¨’°?O
- – –^[ ( YOUR XAT NICK HERE ) ]^– – -
••.•´¯`•.•• ( YOUR XAT NICK HERE ) ••.•´¯`•.••
`•.¸¸.•´´¯`••._.• ( YOUR XAT NICK HERE ) `•.¸¸.•´´¯`••._.•
(¯`•._) ( YOUR XAT NICK HERE ) (¯`•._)
¯¨’*•~-.¸¸,.-~*’ ( YOUR XAT NICK HERE ) ¯¨’*•~-.¸¸,.-~*’
O?°’¨ ( YOUR XAT NICK HERE ) ¨’°?O
×?°”?`”°?× ( YOUR XAT NICK HERE ) ×?°”?`”°?×
¨°o.O ( YOUR XAT NICK HERE ) O.o°
(¯`·._.·[ ( YOUR XAT NICK HERE ) ]·._.·´¯)
¨°o.O ( YOUR XAT NICK HERE ) O.o°
×÷·.·´¯`·)» ( YOUR XAT NICK HERE ) «(·´¯`·.·÷×
· ··^v´¯`×) ( YOUR XAT NICK HERE ) (×´¯`v^·· ·
,.-~*’¨¯¨’*·~-.¸-(_ ( YOUR XAT NICK HERE ) _)-,.-~*’¨¯¨’*·~-.¸
- – –^[ ( YOUR XAT NICK HERE ) ] ^– – -
•·.·´¯`·.·• ( YOUR XAT NICK HERE ) •·.·´¯`·.·•
`·.¸¸.·´´¯`··._.· ( YOUR XAT NICK HERE ) `·.¸¸.·´´¯`··._.·
(¯`·._) ( YOUR XAT NICK HERE ) (¯`·._)
¯¨’*·~-.¸¸,.-~*’ ( YOUR XAT NICK HERE ) ¯¨’*·~-.¸¸,.-~*’
Oº°‘¨ ( YOUR XAT NICK HERE ) ¨‘°ºO
׺°”˜`”°º× ( YOUR XAT NICK HERE ) ׺°”˜`”°º×
.·´¯`·-> ( YOUR XAT NICK HERE ) <-·´¯`·.
<((((º><.·´¯`·. ( YOUR XAT NICK HERE ) ¸.·´¯`·.¸><((((º>
- -¤–^] ( YOUR XAT NICK HERE ) [^--¤- -
~²ºº²~ ( YOUR XAT NICK HERE ) ~²ºº³~
._|.<(+_+)>.|_. ( YOUR XAT NICK HERE ) ._|.<(+_+)>.|_.
..|..<(+_ ( YOUR XAT NICK HERE ) _+>..|..
-·=»‡«=·- ( YOUR XAT NICK HERE ) -·=»‡«=·-
•°o.O ( YOUR XAT NICK HERE ) O.o°•
––––•(-• ( YOUR XAT NICK HERE ) •-)•––––
(¯`•¸·´¯) ( YOUR XAT NICK HERE ) (¯`·¸•´¯)
··¤(`×[¤ ( YOUR XAT NICK HERE ) ¤]×´)¤··
—(•·÷[ ( YOUR XAT NICK HERE ) ]÷·•)—
·ï¡÷¡ï· ( YOUR XAT NICK HERE ) ·ï¡÷¡ï·
·!¦[· ( YOUR XAT NICK HERE ) ·]¦!·
°º¤ø,¸¸,ø¤º°`°º¤ø,¸ ( YOUR XAT NICK HERE ) °º¤ø,¸¸,ø¤º°`°º¤ø,¸
»-(¯`v´¯)-» ( YOUR XAT NICK HERE ) »-(¯`v´¯)-»
°l||l° ( YOUR XAT NICK HERE ) °l||l°
•°¤*(¯`°(F)( ( YOUR XAT NICK HERE ) )(F)°´¯)*¤°•
—¤÷(`[¤* ( YOUR XAT NICK HERE ) *¤]´)÷¤—
¸.´)(`·[ ( YOUR XAT NICK HERE ) ]·´)(` .¸
·÷±‡± ( YOUR XAT NICK HERE ) ±‡±÷
+*¨^¨*+ ( YOUR XAT NICK HERE ) +*¨^¨*+

How to use .Xmodmap to swap keys in [Ubuntu] Linux

I recently reinstalled Ubuntu 11.04 on my laptop since my old install had been upgraded all the way from 8.04 and stuff was just too broken. It was also a good opportunity to just mass-erase all the junk on my laptop that I forgot about / didn’t need anymore. I used Clonezilla to image it to an external HDD and rsync’d over my home directory so I could keep all the useful stuff and have a back-out plan should things blow up in my face.

By far, the most annoying problem to solve was trying to get the alt key back to “where it should be”. The great Apple wired keyboard is great, except for the strange key layout. It has no printscreen on insert keys (which I covered with registry hacks in a blog post long ago) and it has Command where Alt should be. In Ubuntu, Command becomes the Windows key becomes the Ubuntu key, and just pops open the equivalent of the start menu.

Since I use alt+tab to switch windows exclusively (I even disable the task bar because I never look at it), this is highly annoying. I also use Alt + q and Alt + w in Gnome-Terminal to switch between tabs; something I do hundreds of times in a day.

I finally figured it out, and instructions around the internet weren’t that much help. Here is what my .Xmodmap looks like:

remove mod4 = Super_L
keycode 133 = Alt_L
remove mod1 = Alt_L
keycode 64 = Super_L

That does the following, in order (which matters):

  1. Removes Super_L (which is our Command / Windows key) from the list of keys that activate the mod4 function (xmodmap -pm will show you a list if you’re curious)
  2. Sets the Command key (keycode 133…the right one is keycode 134) to the Alt_L function
  3. Removes Alt_L from the list of keys that activate the mod1 function
  4. Adds the left Alt key (Option) to the list of keys that activate the Super_L function

It still doesn’t REALLY make sense, since I would think that you could just unbind keycode 133 from everything first, then do the same for left alt, then re-bind them accordingly…but once again, X shows how silly it insists on being here.

Have fun!

    Mad Science – A Python benchmarking framework

    I’m working on a benchmarking framework at work for a performance enhancement testing project and I’ve decided to call it Mad Science. I decided to do my first real project in Python at the same time, and it looks like it’ll be a great tool! Still having a bit of trouble because I’m used to things like variable substitution, but ‘pexpect’ seems to be the perfect thing to base the testing around. Basically, the framework will do these things:

    - Log in to a remote server via SSH
    - Make atomic changes to config files and / or software
    - Run local benchmarking tools against the remote host
    - Log all of the above in addition to the benchmark results

    As far as I know, there isn’t anything that is tailor-made to this task out there right now. I’m hoping that my testing framework will be useful to other people looking to do the same thing in their environment when it gets closer to a release

    Clicky kitty to check it out!


    Compulsory Registration Sucks — dynaTrace AJAX Edition Download Links

    Dear companies everywhere,
    Stop with the compulsory registration BS. I will continue to use free a mail service which I will not name here and never check them, so really, all you’re doing is polluting the Internet with more spam. If it’s a free trial, let me try it for free without bugging me. Want to keep track of downloads? Figure out another way; there are many. Don’t require that I register.

    For those who don’t know: bugmenot.com is great, but unfortunately, they let companies bully them into “banning” certain sites (and usually the most annoying ones).

    So, I give you…links to download dynaTrace AJAX Edition without going through their stupid BS site. dynaTrace, if you’re reading this…I’ll take these down when you disable compulsory registration. Thanks for the “free” software!

    Filename: dynatrace-AJAX-edition-3.0.0.705.msi

    http://www.multiupload.com/RAKB8W9C35
    http://www.badongo.com/file/25260432
    http://www.zshare.net/download/884367361e83d762/
    http://rapidshare.com/#!download|28dt|455163364|dynatrace-AJAX-edition-3.0.0.705.msi|57057
    http://depositfiles.com/en/files/g3zc2k0yf
    http://www.zshare.net/download/88436707dd87d563/
    http://uploading.com/files/a9bb8c3a/dynatrace-AJAX-edition-3.0.0.705.msi/

    Please leave a comment if somehow all those links go dead. Or, you can use a REAL product, like Firebug, which doesn’t require idiotic pointless internet-polluting poisonous compulsory registration.

    PHP R1Soft CDP Backup Server API Library

    I’m working on making a library that lets you easily use the R1Soft CDP XMLRPC API. The default way of using the R1Soft API really sucks and involves way too much work to get useful info out of it. Also, it doesn’t return arrays with keys named after the values like they should be. My library will fix that. I might not implement all features, but if you need something implemented, please leave a comment and I can probably do it for you. I’ll put this up on bitbucket when I’m finished with it, but it’ll probably be just a component of my R1Soft CDP 2.x multiple server monitoring app that I’m working on.

    Requirements

    • The awful PHP XMLRPC lib with incomplete documentation that is a whole release behind!  Name it ‘xmlrpc.inc’ and put it in the same dir as this lib
    • Access to the admin account on your R1soft CDP Backup server(s)
    • PHP >= 5.x should work.
    <?php
    class r1api {
        public $r1password;
        public $r1username;
        public $r1host;
        public $r1port;
        public $r1XMLRPCPath;
    
      function __construct($r1username, $r1password, $r1host, $r1port = '8084', $r1XMLRPCPath = '/xmlrpc') {
        include 'xmlrpc.inc';
        $this->username = $r1username;
        $this->password = $r1password;
        $this->host = $r1host;
        $this->port = $r1port;
        $this->path = $r1XMLRPCPath;
        $this->xmlrpcclient = new xmlrpc_client($this->host . ':' . $this->port . $this->path);
        $this->xmlrpcclient->setCredentials($this->username, $this->password);
      } //function __construct
    
      function getIDs() {
        $xmlrpc_msg = new xmlrpcmsg('host.getHostIds');
        $reply = $this->xmlrpcclient->send($xmlrpc_msg);
        $xml = $reply->value();
        return $xml->getVal();
      } //function getIDs
    
      function getHost($hostID) {
        $this->hostID = $hostID;
        $xmlrpc_msg = new xmlrpcmsg('host.getHost' ,  array(new xmlrpcval($this->hostID, 'string')));
        $reply = $this->xmlrpcclient->send($xmlrpc_msg);
        $xml = $reply->value();
        $inarr = $xml->getVal();
        $outarr = array( 'hostID' => $inarr[0],
          'hostName' => $inarr[1],
          'hostType' => $inarr[2],
          'volumeID' => $inarr[3],
          'isEnabled' => $inarr[4],
          'isControlPanelModuleEnabled' => $inarr[5],
          'quota' => $inarr[6],
          'diskUsage' => $inarr[7],
         );
        return $outarr;
      } // function getHost
    
    } // class r1api
    ?>
    

    Usage:

    <?php
    include("r1.php");
    
    $myr1 = new r1api('admin', 'some-admin-password', 'some-r1cdp-server.example.com');
    foreach ($myr1->getIDs() as $value) {
      var_dump($myr1->getHost($value));
    }
    ?>
    

    Example of what the usage example will output:

    array(8) {
      ["hostID"]=>
      string(36) "6c657587-ec55-4f29-b85c-523cee90216c"
      ["hostName"]=>
      string(19) "some-server.example.net"
      ["hostType"]=>
      int(0)
      ["volumeID"]=>
      string(36) "2204ff39-2b19-46a1-b5fb-5166a9fedc50"
      ["isEnabled"]=>
      bool(true)
      ["isControlPanelModuleEnabled"]=>
      bool(false)
      ["quota"]=>
      float(-1)
      ["diskUsage"]=>
      float(148676275346)
    }
    array(8) {
      ["hostID"]=>
      string(36) "89bc9d17-c0b9-426b-9cce-6f96405f1b5f"
      ["hostName"]=>
      string(19) "some-other-server.example.net"
      ["hostType"]=>
      int(0)
      ["volumeID"]=>
      string(36) "2204ff39-2b19-46a1-b5fb-5166a9fedc50"
      ["isEnabled"]=>
      bool(true)
      ["isControlPanelModuleEnabled"]=>
      bool(false)
      ["quota"]=>
      float(-1)
      ["diskUsage"]=>
      float(256312020360)
    }
    

    More to come. Enjoy. Questions / comments / feature requests welcome. If you want lots of features implemented I’d consider doing it for a small donation and the results would be released for all to use.

    Page 2 of 612345...Last »