Friday, July 29, 2011

Plumbing pipes and fittings comparison

Copper pipes must be replaced.  Minute holes developed in copper pipes over time lead to leaks, and millions of homes have no insurance once that sort of flood occurred.

Replacing all the copper in the home with plastic and sell the copper will make your a fortune.

The advantage of copper remains that it is rigid metal, and you can burn it without problem.  Also it act as earth point for the electrical system in homes.

Copper can be replaced by CPVC and PEX.  The other camp is PVC which is not copper compatible.  PVC is usually found outside houses for the main supply, and for irrigation.  PVC is not usually found inside houses as it cannot be used for hot water.

If your pipes are PVC, it does not make sense to change it to something else.  Unless you need to connect to metal devices.  I'm not sure what the code is, but screw them together is pretty easy and leak proof.  But anyway, threads are trouble.

In the copper/CPVC/PEX camp, all can be connected with push fittings.  CPVC is rigid, using glues, while PEX is flexible and uses clamps.

Almost certainly PEX is the material of choice whenever you can.  You don't need angle couplings to go round corners.  The total number of joints is less.  With clamps you can use it immediately.  If you don't want to invest in a good clamp for over $100, you can get push fittings at a few dollars each.

Measurements no longer need to be accurate, as long as the pipe is longer than what you wanted. For example, to replace a broken section of copper pipe or CPVC, you need to cut pipe to exact length and use unions to connect to the old pipes.  For PEX you just need two adapters and a length of pipe longer than the bad section.


Fittings/couplings/joining

Soldering copper pipes need a lot of clearance from the sides, or else you need a soldering shield.  Glues are best when you have little space to work with.

Push fit need to have clearance along the pipe to push things in, and to take it out.

Soldering and gluing are rigid joints while push fit couplings can be rotated freely.  This could be a good or bad point.  Ball valves with push fit ends are still able to rotate after you install it.  You need two hands to operate the valve handle.

Threads are trouble but they are compact compared to other reusable push fittings.  In practice, never assume that they are reusable.  The threads are so easily damaged when you screw it back again.  Often you can't even unscrew them apart in the first place.


Gatorbite vs Sharkbite

I used both but can't comment much other than that they works.  Threads always start dripping at the beginning, but somehow hard water seals the threads.

When you put two devices with push fit together, you need to use a short pipe to connect the two.  It's is bulky.  I was too stupid to use too short a pipe, and I can't even put the disconnect tool in place.  I saw the two apart.  The good thing about Sharkbite is that no matter how short the pipe left alone inside the coupling, you can take it out with a nose pillar and some patient.

Monday, July 25, 2011

Auto startup applications in Ubuntu Linux

Ubuntu has a startup menu as in Windows.  It's at System>Preferences>Startup Applications.  It's fine if it's a GUI user application.

If your application has no GUI, such as a command or a script, you can put it in .login.  Of course NOT, now they use .profile if you the default Gnome desktop.

Many applications can be a command or with GUI.  You can pick one of the two methods.

Many times you have a mix of both such as in a script, or you do not want to learn both methods.  Now here's some techniques for mix and match, either using .profile or Startup Applications.

First, the most troublesome are commands/apps that require privilege access.  "sudo yourcommand" do not usually works in Startup.  Instead you need "su-to-root -X -c command".  -X means it's GUI.

To eliminate superuser password prompt on some of the apps, you can do:

sudo visudo

add the following line to the end of the file:

yourusername ALL = NOPASSWD: /usr/sbin/firestarter, command2, etc

Never force edit when there are parse errors, or you need to go into recovery mode.  (The safer alternative using sudoers.d do not work using the same syntax.)

To run a command as a GUI program, all you need to do is give it a GUI terminal:

gnome-terminal -e "your command"

It's also the simplest way to say Hello World in Gnome.

Many times you don't really need the Startup App.  For example, you can put this in the .profile:

truecrypt mountfile /media/truecrypt1

Obviously the best thing about Linux is that backup is easy (via a command and cron) and built-in.  Backing up encrypted volumes into encrypted volumes is also the same.  You just need to mount the volume as above and then backup.  The alternative is to copy the whole encrypted volume, a few GB or much more usually, that you don't want to every day.  You can do incremental backup every hour.

In Windows it's terrible. 

Tuesday, June 21, 2011

Ubuntu 11.04

I didn't touch Ubuntu until I have to upgrade about 2 major versions.  Actually I was forced to upgrade because the old one wasn't supported any more.  I kept updating by default until it was 10.04, and no more.  I was happy that nothing broke.  There was but you can fix it somehow or leave it alone.

Now when I was totally enjoying it, especially the gnome applets, I saw the new 11.04.  I tried to upgrade and find out that I have to upgrade to 10.1x first.  You have to push a button instead of by default.

After two major upgrades and fixed some broken stuff, only to find out that gnome applets are history.  So what worked on my last goodies post won't work at all, or looks differently.

I like the new Unity 3D GUI.  It's space saving.  In MS Windows terms, the whole status bar integrates with the quick launch area, and it's auto hide.  Also title bar of applications integrate with the menu bar.  So it's back to Windows, you have only one bar normally visible.  Also the scroll bar becomes hair lines when you are not using it. 

There are themes and 3D effects but I'm not up there yet.

I switched back to the Ubuntu Classic GUI.  You can do it when you login.

Monday, June 13, 2011

Ubuntu goodies


My wireless router and firewall broke.  Before reinforcement arrives, I found a soft firewall - Firestarter.  It's better than anything else, including a hardware box.

Linux has a pretty good firewall built in.  All you need is a easy to use GUI.  A resident firewall manager is easier to use than any separate firewall box.  Firestarter understands the software that needs external connections such as Openvpn and Tor.  If you install those from the package managers, it's likely Firestarter understands it.

Being resident, Firestarter notifies you when an attempted attack occurs, which is frequent if you surf the net unprotected.  Attack means attempt to connect to your machine.

You can be paranoid enough to allow selected applications to use the internet.  It can be like Zone Alarm if you like to.

More useful to me is not the firewall functions.  You can see active connections.  I can see what traffic is routed through my VPN, my proxies, or chained.  It is simple enough that I can actually make good sense of it in real time.

The bad thing is that your external IP is stored on your computer.  Spyware can just read it.  But still they have to get external connection to report the IP.  If they get an external connection, in theory they can bypass your proxies and VPNs to get your real external IP.  It's not likely though.

The other goodie is the Windows equivalent of the task bar, as shown.  You can almost install or drop anything into it, plus select almost any picture for your icon.

Your can have your own script, add an icon to it, and put it on the task bar.  Firstly it's so simple that you can have two versions of everything.  When your fingers are on the keyboard, the need to pick up the mouse is greatly reduced.  When your hand is on the mouse, the need to bring up the terminal is also greatly reduced.  You can have one task bar to as many as you want.

A month without booting into Windows.  When it's cool to use Google Docs, there's no need to.  Google Docs is better with auto save and auto version control.  The version control in Words is laughable, and therefore you probably never heard of it.

Sunday, May 1, 2011

1st line of backup defence - external USB drive

So I can't stand the 100 KB/s upload speed for Amazon S3.  It's worse than that.  The gsutil is supposed to upload in multiparts in 1MB trunks.  Boto supports that.  But it may be true for Google Storage, but I doubt if it's for S3 too.  And I couldn't find out if there's an option to force multiparts.  A 2GB file failed when > 1.5GB was uploaded.

I still like the clouds but I made a pack with the devil, brought a 1 TB external USB drive as the first line of defense.  I never did that because for less you can have a bigger and faster internal drive.  And you can use the older drive for backup.

You fill better if all your drives are not in the same casing.  As you can see, the WD Element 1 TB can sit nicely in the smallest fire proof (1.5 hr?) safe with space to spare.

The WD Element is about 7x5x1.5 inch.  It's fully enclosed except for a small power jack, a small USB 2 connector, and a small LED, all next to each other.  It looks like it can survive being sprayed with a hose.

If you place the connector at the back side away from you, you will not see the LED, only a black box.  And actually the LED is brighter than you think, if you are not dead center looking at it, like sitting in front of a desk looking down at the desktop.

It's pretty quiet.  The plastic looked cheap but the box feels solid.  I bet the drives are so small that a lot inside are padding materials to make the box quiet and feels solid.  I would say it's portable if you wrap it in a little shock absorbing material just in case.  It was sent to me in the mail with air bubble packages.

There is the power cord and there is the USB connector.  It doesn't matter which one go first and you can't go wrong.  Once it's on and connected, a WD Element icon appears on my desktop, and I'm using Ubuntu Linux!  It's pre-formatted in NTFS, the Windows file system after XP.  It can be used in Linux, just that you do not have undelete when you delete a file.

The 1st thing I did was ran into a Ubuntu disk utility to test the drive.  I was luck that I ended up first is looking at the SMART data logged in my old disks.  Failure is imminent for my oldest disk.  I remembered that it was absent for a while, and I remembered it failed to spin up, sounding like a failing fridge compressor.

I downloaded some SMART in Windows but I never remembered to look at it again.  In Ubuntu it is pre-installed, which may have saved my life.

I tested the WD using the disk utility.  It passed the short tests, but the long ones cannot survive power management, which shut down something or put something to sleep.  It would be terrible to scan the entire 1TB for errors.  So I'll be watching the SMART data when there's more data stored in it.

Now the performance.  It's only about 20 MB/s for backing up huge files.  It's not particularly fair as I'm copying from a pretty full disk to an empty disk.  For the disk read-only benchmark test it is:

Max Rate 39.2 MB/s   Average Rate 37.9 MB/s    Access Time 16.0 ms   USB2
Max Rate 86.6 MB/s   Average Rate 67.9 MB/s    Access Time 13.4 ms   SATA

My motherboard should support USB2.0 but I used the monitor hub.  The SATA should be II, claiming up to 3 Gb/s transfer.  Again one drive is pretty full and the other is empty.

If I'm copying a small file (<1G), it doesn't matter that much.  If I'm backing up it will not be interactive and the time taken doesn't that much.  It will matter if you need overnight to backup your things, then one night and two night will make a lot of difference.

It can't go too wrong.  There are more than a thousand reviews.  The model is old and established.  And it's cheap.

Wednesday, April 27, 2011

Cloud storage solutions: s3cmd boto gsutil

s3cmd is good for Amazon S3.  It's in python too, so you can also use it in Windows or wrap it up.  There are two things critically missing - multipart upload and parallel upload.

There is a branch on s3cmd for "parallel" upload.  I downloaded, only to find out that it doesn't improve anything.  I think if you are uploading to the same account via the same IP, the limiting speed is the same.  That's the reason the patch wasn't added to the main s3cmd.

The multipart upload is implemented in boto.  The problem is that it's just a wrapper in python for the S3 (and all AWS) API.  I downloaded some user scripts that uses boto.  It works but only if you just want to upload a large file to the root of a bucket.

In the search for someone embedding boto, to my surprise it is gsutil - for google storage.  I understand a few things.

Now that the giant is closing in, I wonder if the incentive of updating S3 tools is great.  Google Storage is slightly more expansive in storage, about the same in bandwidth, but the promotion is 100 Gb free per month!  The problem is that I have no idea if they will give me an account after I submitted an almost blank form with nothing to say, and how long I have to wait.

I understand why Amazon have the 1 year free promotion.  And why they recently added the multipart upload and resumable download (?) API.  Everybody will switch to GS without that.

Go to gsutil in Google code to download and install.  They have good instructions for that.  But it wouldn't work.  Because developers' Ubuntu isn't the same Ubuntu as you and me!

After installed gsutil in your home directory, you cd into gsutil, edit the gsutil file and search for the line:

def SanityCheckXmlParser(cmd):

Then, right below the line, add a line with two spaces and the word

  return

That will make it work.  You also need to setup ~/.boto file like this


[Credentials]
aws_access_key_id = your id key
aws_secret_access_key = your secret key

[Boto]
debug = 0
num_retries = 10

I think if you don't have anything, gsutil will ask you, but for GS only, or not.

The documentation (or lack of it) says gs:// but it will also works for s3://, exactly the same, or not.  The syntax is similar to s3cmd but more like Linux.

To copy the whole directory (and subs):

gsutil cp -R mydir s3://myuniquebucket

Large files are probably uploaded in 1M chunks (or not).  To copy subdirectories, -R option is necessary for s3.

Unfortunately gsutil doesn't sync.  But since gsutil is rather reliable with multipart upload, you don't need to sync that often.  When you added something or just wanted to check, you can use s3cmd:

s3cmd sync mydir/ s3://myuniquebucket/mydir/

Note the slashes at the end, without which s3cmd will check more than that.  If s3cmd detected that you need to upload a large file, you are better off to upload the file yourself by gsutil.

Now that's the complete solution.  Three packages to do something simple.  You may want to pay up for the commercial software.

Now I can backup my large encrypted containers.

Monday, April 25, 2011

Multipart Parallel upload to Amazon Simple Storage Service using boto

The comment I received on upload to S3 trigged me to do some research (or some googling).  Life is short and we always need something to save time.

Yeah, in Windows I tried one of the free uploaders.  It's like using file explorer after asking for your id key and secret key.  It's fast and error free.  I don't remember if I have large files in there, and I would think retries will be hidden from view.

What to look for is multipart (relatively new S3 protocol) and parallel upload, and of course automatic retry.  Basically it's more like ftp, where you see the files are split into trunks and  transferred in many parallel threads.

Multipart upload allow behavior like "resume".  If you lost one file trunk you just need to retry that trunk.  The transfer speed depends on both end of each connection, but the number of connections is not limited to one.

Most Windows uploaders have both in the commercial versions.  You may or may not find it in the free versions.  The problem is, I haven't booted into Windows for weeks now, and I have no intention to if not necessary.

In Linux it's a different story.  Some good uploaders don't have Linux versions.  s3cmd is good and free, but it doesn't support multipart nor parallelism.  You can see that it upload one file at a time, with retry on errors.

After googling I came across the one and only one boto package.  I also copied the one and only one complete script that demonstrate multipart and parallel upload.

First, boto is written in python, so you can also try it in Windows.  Of course python is already in my Linux, and I didn't know if it was me who installed it.  (I'm the only supervisor.)  Also, boto is already installed, but I didn't know if it was me.

But the boto in my Linux is old.  You need the latest boto, 2.x.  You have to uninstall the current version using any one of the usual methods.  Download boto from the official site.  I unzip the .gz file using the archiver via the GUI.  I don't even know the command to unzip it.

After some guessing, I figured out how to "install" the new version.  You change directory to where the setup file is.  Then use the command:

$python setup install

To try multipart upload, create myuniquebucket using the S3 control console, at the reduced redundancy rate, the cheaper rate.  I think the rate dependents on your bucket, determined at creation.

Copy the "bio" script or any other script you want to try.  I removed the reduced redundancy option in the script because it got complains from python.

To run boto, first you need to edit the ~/.boto file to declare the id key and secret key.  See the official boto site.  Download, modify the upload script somewhere.  Then

$python s3multi.py bigfilename myuniquebucket

Maybe I post my configure file and the bio script later.  This script works as intended but far from an end user product.

It is not obvious how you specify the size of the parts.  If the files are over 10M you may think that the script hangs.  I am getting 100K/s upload rate.  You need some signs of life like in s3cmd, when the parts are large.

The script uses all your cores, or threads in a multithread CPU.  For me it's two.  I don't know if you can maximum my 10M cable modem connection by more parallelism.

The script uploads one file, in whole or in parts.  You still need to call the script from other directory sync scripts.  I do not know if the script will upload to subdirectories.