GEEK: Ruby scripts to compare the contents of directory to svn

A pair of functions I wrote that compare the contents of a configuration directory on a remote server with the expected contents in SVN. compareDir is the first draft and compareDirTwo is the second draft. compareDirTwo compares all of the files in all the directories below, whereas the compareDir only goes one level and doesn't compare the files in the topmost level. The compare flag will cause the function to compare the contents of the files, in addition to checking for existence. It assumes that all files are text files. Pasted here to remind me how I wrote the compareDir function, because I'm deleting it and it has some tricks in it that I want to remember.

def compareDir(host, location, svndir, actualdir, *rest)
    puts "Now comparing the #{actualdir} on #{host}, #{location} with the directory in svn: #{svndir}"
    status = "pass"
    differences = ""
    result = ""
    linebreak = "="*80 + "\n"

    puts message = "host: #{host}\n"
    puts "\n"

    svndirlisting = %x[ svn list #{svndir}]
    tunnel = SSHTunnel.new(host, location)
    actualdir_listing = tunnel.remoteExecute("find #{actualdir} -type d -maxdepth 1 -mindepth 1").to_a
    actualdir_listing.each do |dir|
        puts linebreak
        puts "dir: #{dir}\n"
        message += linebreak
        message += "dir: #{dir}\n"
        dirname = dir.chomp.split(/\//)[3]
        file_list = tunnel.remoteExecute("find #{actualdir}/#{dirname} -maxdepth 1 -mindepth 1").to_a
        file_list.each do |file|
            filename = file.chomp.split(/\//)[4]
            svnfilename = "#{svndir}/#{dirname}/#{filename}"
            svnfile = %x[ svn cat #{svnfilename} ]
            actualfile = tunnel.remoteExecute("cat #{file}")
            differences = stringDiff(svnfile, actualfile)
            if differences != ""
                    puts result = "FAILED:\n"
                    status = "fail"
            else
                    puts result = "PASSED:\n"
            end
            puts filenames = "svn: #{svnfilename} \nactual: #{file}\n"
            puts differences
            message += result
            message += filenames
            message += differences
        end
    end
    tunnel.destroySSHTunnel

#        puts message

    if status != "pass"
             flunk
    end
end
def compareDirTwo(host, location, svndir, actualdir, compare="true", *rest)
    puts "Now comparing the #{actualdir} on #{host}, #{location} with the directory in svn: #{svndir}"
    status = "pass"
    differences = ""
    result = ""
    linebreak = "="*80 + "\n"

    puts message = "host: #{host}\n"
    puts "\n"

    puts "svnlist:\n"
    svn = %x[ svn -R list #{svndir}].to_a
    # Get a list of all files/directories from svn.  Remove  the trailing / from directories. Prepend the base directory.
    svnall = svn.collect { |name| actualdir + "/" + name.chomp.gsub(/\/$/,'') }
    svnall.map { |file| puts "#{file}" }

    puts linebreak
    puts "svnfiles:\n"
    # Get a list of only files from svn
    svnfiles = svn.delete_if { |name| name =~ %r[(.*)/$] }
    svnfiles.map { |file| puts "#{file}" }

    puts linebreak
    tunnel = SSHTunnel.new(host, location)
    actual = tunnel.remoteExecute("find #{actualdir}").to_a.collect { |name| name.chomp }
    actual = actual.delete_if { |name| name == "#{actualdir}" }
    puts "actual:\n"
    actual.map { |file| puts "#{file}" }
    if compare:
        svnfiles.each do |file|
                 svnfilename = "#{svndir}/#{file}"
                 svnfile = %x[ svn cat #{svnfilename} ]
                 actualfile = tunnel.remoteExecute("cat #{actualdir}/#{file}")
                 differences = stringDiff(svnfile, actualfile)
                if differences != ""
                        puts result = "FAILED:\n"
                        status = "fail"
                else
                        puts result = "PASSED:\n"
                end
                puts filenames = "svn: #{svnfilename} \ractual: #{actualdir}/#{file}\r"
                puts differences
                message += result
                message += filenames
                message += differences
        end
    end
    tunnel.destroySSHTunnel

    differences = actual - svnall
    if differences != []:
        puts "These files are in the #{actualdir} directory on #{host}, #{location} but are not in svn:\n", differences
        message += "FAILED:\n"
        status = "fail"
    end

    return status, message, differences

end

Fallen Art

Via

http://www.youtube.com/watch?v=vC2pBMJLUCo

Some other good stuff:

http://www.youtube.com/watch?v=vQ8tHyPkovQ

http://www.youtube.com/watch?v=J_zREAGnLqQ

http://www.youtube.com/watch?v=QcdQZ8MV5BY

Little Miss Sunshine

Saw Little Miss Sunshine last weekend. I haven't laughed so much during a movie in a long time. Full of black humor, and characters that you love despite (or because of) their flaws. Although the movie occasionally gently pushes against the bounds of plausibility, it felt emotionally real throughout. Fans of The Daily Show or The Office (American version) will also be pleased to see Steve Carrell, albeit playing a straight (so to speak) role. Highly recommended.

Femtroopers

Femtroopers. Heck, I'd join the empire. Via

A new strategy to strip gun ownership rights

http://www.gunlaws.com/Decommissioning%20Scheme.htm

“Decommissioned” Guns Nearly As Good As Confiscation

by Alan Korwin, Author
Gun Laws of America

The Brady group and its congressional supporters are proceeding, and making headway, with a below-radar effort to ban operating firearms from the general public, without having to actually disarm America's 95 million gun owners.

The plan is now evolving around an innocent-sounding new legal term. It was tucked deep in a 400,000-word spending bill under president Clinton (law # P.L. 105-277), and it is now spreading throughout federal gun laws. Its latest use, the eighth, is in the frivolous-lawsuit ban just enacted (The Protection of Lawful Commerce in Arms Act, law # P.L. 109-92; S.397). Described at the end of this report, it accents a liability all Americans — not just gun owners — are increasingly under, a tightening legal noose few people realize is around their necks.

The phrase is “secure gun storage or safety device.” It includes almost anything that will keep a gun from working. At its simplest, it's gun locks.

This and closely related tactics are sometimes called “decommissioning schemes.” Gun-control advocates — the mainstream ones who seek to disarm the public — will essentially win their cause if they can require guns to be disabled, disassembled, locked up or turned off by remote control.

This approach is already working in National Parks where possession of a working gun subjects you to immediate federal arrest, confiscation of your property, and endless aggravation. No criminal act of any kind is required, just legal possession of personal property — any firearm. However, a gun in pieces so it cannot be fired, locked in your car trunk is allowed. Interestingly, no statutory authority for this denial of civil rights can be found. And of course, statutory denial of civil rights would be unconstitutional on its face.

Washington, D.C., is currently under a similar “decommissioning model” too, though its registration system gets more attention. In addition to a full ban on handgun registration since 1976, firearms that were owned before that date cannot be assembled, or even carried — at home. It's almost as good as taking the guns away, from a gun-ban perspective. Any gun use, including legitimate self defense, implies assembly and carriage, and is banned.

Even the widely hailed federal “Firearm Transportation Guarantee” (law # 18 USC 926A) relies on decommissioned guns. It was enacted as part of the Firearm Owners Protection Act in 1986, to help counteract high levels of federal abuse under the 1968 Gun Control Act. It guarantees a person the right to transport a firearm from any legal place to any other, anywhere in the country. However, the firearm must be unloaded and locked in the trunk, rendering it useless. If you bear it in any manner while you travel, the protection does not apply.

Under Brady-supported decommissioning schemes, you can keep your guns, but if they're ever workable, or available, you become a criminal and subject to arrest. It's pretty clever actually. And it has been working, even though forced decommissioning is infringement of the right to keep arms and the right to bear arms.

The Byrne Grant program (law # 42 USC 3760) provides federal money for law-enforcement firearm training and other purposes. Changed under president Clinton, it now authorizes federal funding to train the public in the use of… gun locks. Under a gun-unfriendly administration (anti-rights advocates believe they will have this one day), little prevents this funding from going into large-scale campaigns to convince people to only possess decommissioned guns, “for safety.”

While on one hand, who could rationally argue against making guns safe, gun guru Col. Jeff Cooper has succinctly pointed out that, “A gun that's safe isn't worth anything.”

And that turns out to be the very heart of this gun-ban plan — a gun that's safe isn't worth anything. But gun-rights advocates know guns are dangerous, they are supposed to be dangerous, and they're not any good if they're not dangerous. Anything requiring guns to be “safe” is the true danger, and the secure storage device has now become “incentivized.”

The Republican party, in control for half a decade, hasn't used Byrne Grants for their other authorized purpose: training the public in “the lawful and safe ownership, storage, carriage or use of firearms.” Will Republican failure to use this law (for gun-safety training) also deter Democrats from using it (to promote gun locks)? Nah. And now, with gun locks slipped into the gun-industry protection bill…

As the subtle tactic of decommissioned guns continues, the right to keep and bear arms is at risk. The next time the anti-rights factions slip in the phrase “secure gun storage or safety device,” you had better look very closely. All it will take is one use, with the word “required,” to wipe out our cherished Second Amendment rights. And they won't have to take your guns away to do it.

Next step in the march to Skynet

http://www.defensereview.com/article846.html

“DefenseReview.com has received video footage of a weaponized version of the AutoCopter self-stabilized unmanned mini-helicopter being tested for the first time in sunny Huntsville, Alabama (The download link for this video is further down in this article.). The AutoCopter is made by Neural Robotics Incorporated (NRI), and the weapon portion of the package is a 12-gauge Auto Assault-12 Full-Auto Shotgun (a.k.a. AA-12 Full-Auto Shotgun) made by Military Police Systems, Inc. (MPS). DefRev first reported on the AA-12 back in June of last year (2005). NRI is calling the newly-weaponized AutoCopter the “AutoCopter Gunship”. Catchy.”

see the demo video

How to tell you're a fundamentalist Christian

Probably old to some of you, but new to me:

10. You vigorously deny the existence of thousands of gods claimed by other religions, but feel outraged when someone denies the existence of yours.

9. You feel insulted and “dehumanized” when scientists say that people evolved from other life forms, but you have no problem with the Biblical claim that we were created from dirt.

8. You laugh at polytheists, but you have no problem believing in a Triune God.

7. Your face turns purple when you hear of the “atrocities” attributed to Allah, but you don't even flinch when hearing about how God/Jehovah slaughtered all the babies of Egypt in “Exodus” and ordered the elimination of entire ethnic groups in “Joshua” including women, children, and trees!

6. You laugh at Hindu beliefs that deify humans, and Greek claims about gods sleeping with women, but you have no problem believing that the Holy Spirit impregnated Mary, who then gave birth to a man-god who got killed, came back to life and then ascended into the sky.

5. You are willing to spend your life looking for little loopholes in the scientifically established age of Earth (few billion years), but you find nothing wrong with believing dates recorded by Bronze Age tribesmen sitting in their tents and guessing that Earth is a few generations old.

4. You believe that the entire population of this planet with the exception of those who share your beliefs — though excluding those in all rival sects – will spend Eternity in an infinite Hell of Suffering. And yet consider your religion the most “tolerant” and “loving.”

3. While modern science, history, geology, biology, and physics have failed to convince you otherwise, some idiot rolling around on the floor speaking in “tongues” may be all the evidence you need to “prove” Christianity.

2. You define 0.01% as a “high success rate” when it comes to answered prayers. You consider that to be evidence that prayer works. And you think that the remaining 99.99% FAILURE was simply the will of God.

1. You actually know a lot less than many atheists and agnostics do about the Bible, Christianity, and church history – but still call yourself a Christian.

Grand Theft Auto: Coca Cola

GTA: Coca Cola

Edouard Martinet

Via :

Edouard Martinet's mechanical sculptures

Awesome stuff.

Alien My Little Pony

Via :

Alien My LIttle Pony