Enforcing Privacy

Unlike almost all other developed countries, the US does not protect personal privacy, and vendors who mangle and lose your personal or business data pay no penalty. The ACLU wants to change that and has released a new report, ENFORCING PRIVACY


EXECUTIVE SUMMARY

Privacy laws are of limited value if institutions for enforcing such laws do not exist. The United States, unlike nearly every other advanced-industrial nation, does not have an independent data protection official or privacy commissioner to fill that role. We recommend that Congress take several steps to bridge this gap:

  1. Activate the independent Privacy and Civil Liberties Oversight Board (PCLOB) and expand its scope and powers to turn it into a full-fledged privacy body with oversight of all government agencies.
  2. Supplement the strengthened PCLOB with multiple overlapping layers of privacy protection, by creating a statutorily mandated Privacy Advisor within the White House’s OMB, and bolstering and expanding federal agency privacy offices.
  3. Create an independent federal privacy commission to serve as a full- fledged private-sector privacy regulator.
 
Posted on Nov 16, 2009 by: Fred Cirera @ 15:49 Leave a comment Comments: 0

Prime number generator in Python

The Sieve of Eratosthenes [en.wikipedia.org] is a fast and simple algorithm to generate all the primes in a range.

Lists

In our first example we use lists. In each loop we take the first number of the sequence and use the filter to remove every multiple of that number. When the sequence is empty we stop the loop and return the list of prime numbers we have found.
def eratos(upperBound):
        primes = []
        seq = range(2, upperBound + 1)
        while True:
                try:
                        p = seq[0]
                except IndexError:
                        break
                seq = filter(p.__rmod__, seq)
                primes.append(p)
        return primes

def eratos(upperBound):
primes = []
seq = range(2, upperBound + 1)
while True:
try:
p = seq[0]
except IndexError:
break
seq = filter(p.__rmod__, seq)
primes.append(p)
return primes


Iterators

The following example uses the same algorithm, but with Python “iterators” instead of lists. The main advantage with this method is that we don't have to pre-allocate any sequence of numbers in memory.
from itertools import count, ifilter
def i_eratos():
    seq = count(2)
    while True:
        p = seq.next()
        seq = ifilter(p.__rmod__, seq)
        yield p

from itertools import count, ifilter
def i_eratos():
seq = count(2)
while True:
p = seq.next()
seq = ifilter(p.__rmod__, seq)
yield p


Using this method I managed to generate more that 131.000 prime numbers, before Python crashed with a Segmentation fault message.
 
Posted on Oct 26, 2009 by: Fred Cirera @ 09:44 Leave a comment Comments: 0

Read a single character in shell

Sometime as IT we need to develop shell script who interact with end users (yeuk). In these programs you may want to ask the user question like press any key to continue. Also for ease of use you may want to ask them to press the key Y or N to confirm or not an action, without asking them to press return each time you ask a question. Here an example on how to do that in your favorite shell.

anykey() {
    stty cbreak -echo
    KEY=`dd bs=1 count=1 2>/dev/null`
    stty -cbreak echo
    echo $KEY
}

anykey() {
stty cbreak -echo
KEY=`dd bs=1 count=1 2>/dev/null`
stty -cbreak echo
echo $KEY
}

Usage:

echo -n "Press any key: " && anykey

echo -n "Press any key: " && anykey
 
Posted on Apr 07, 2009 by: Fred Cirera @ 07:35 Leave a comment Comments: 0

Convert text files from DOS to UNIX and vice versa.

Here are few recipes to convert DOS text files to UNIX.

How do you know whether you have a DOS text file or a UNIX text file? A line feed and a carriage return terminate the DOS text files lines. UNIX uses only a line feed character. By using the Unix command file you can figure out which type of file you are dealing with.
$ file dosfile.txt 
dosfile.txt: ASCII text, with CRLF line terminators
$ file unixfile.txt 
unixfile.txt: ASCII text

$ file dosfile.txt
dosfile.txt: ASCII text, with CRLF line terminators
$ file unixfile.txt
unixfile.txt: ASCII text

To convert files back and forth from one format to another you have several options. A few of them are showed here.
 
Posted on Feb 22, 2009 by: Fred Cirera @ 14:03 Leave a comment Comments: 0

X11 on MacOS X and CMD-W

The most annoying thing with X11 on Mac is the shortcut CMD-W, especially when you are an Emacs user. On Emacs, CMD-W or META-W is the shortcut to put your selection into the cut buffer. But on Mac this is also the shortcut to close the window. This means that every time you type META-W on Emacs your Emacs window closes and you loose everything you are doing.

This recipe will explain how to remove the annoying CMD-W shortcut on X11.

 
Posted on Feb 21, 2009 by: Fred Cirera @ 15:22 Leave a comment Comments: 0

Twitter Weather station

Create your own weather station on Twitter.

With these few simple steps and this following code, you can have the weather information from where live automatically updated to you twitter account. These following steps are for a Unix/Linux/Mac environment but I am sure they can easily adapted on Windows.
 
Posted on Feb 17, 2009 by: Fred Cirera @ 22:35 Leave a comment Comments: 60

Print messages on a mini LCD.

At work, I manage a cluster of several hundred nodes. All those nodes are equipped with a little LCD display, like to one showed in the picture on the right. Until now, these displays were only displaying the name of the cluster vendor at boot, and the node name when the machine was up an running. To put these neat little displays to better use, I wrote a Python program named lcd.py, which prints more useful information.

When started, lcd.py burns into the MVRAM of the display the name of the company I am working for and the name of the node, which is in fact the position of the node in the rack. This helps me find which node is which when I take several of them out of the rack for maintenance. I just power the machine for a few seconds to read its name and position on the racks on the LCD display .

Then, the daemon goes into an infinite loop to probe the disk temperature using the S.M.A.R.T information provided by the disk. This information is then displayed on the second line of the LCD display. A quick look at the display and I know if something is wrong with the disk or the machine. Of course this is not the only monitoring system used to watch the system but every little detail helps. And it is fun to use these little displays.

The program also pings the “master node” to see if there are any network problems. If the “master node” cannot be reached, the program turns off the LCD display backlight. A quick glance at the entire rack and you know which node is in trouble.

For more information on these LCD display you can download the manual.

Download the entire source code

 
Posted on Feb 13, 2009 by: Fred Cirera @ 22:18 Leave a comment Comments: 0

Heartbeat code for cluster environment

Working in a cluster environment, I often need to check in my Python programs, if some of the nodes of my cluster are dead or live. To do so I have in my Python toolbox, a class called Heartbeat. This is a simple heartbeat class does a ping on the cluster node, and return True, or false depending on the health of the targeted node. This class implement a stripped down version of ping. It send a ICMP_ECHO_REQUEST packet and wait for the answer.

To use this call I call the constructor with the node name, or IP address, followed by the number of seconds between heartbeats. Then every time I need to check in my program if the node is still alive, I call the method is_alive() which returns a Boolean.
 
Posted on Jan 31, 2009 by: Fred Cirera @ 23:46 Leave a comment Comments: 0

Intel Core i7 vs Core 2 Quad

Insidehw ran a bechmark test between an Intel Core 2 Quad and an Intel Core i7. This test shows that the Core i7 is slightly faster than the Core 2 Quad, but not enough to justify the price difference between the two.

If you are planing to upgrade your machine from a Core 2 to a Core i7, you also have to add the price of a new motherboard and new memory. Which makes the upgrade way too expensive for a not that noticeable performance gain.

Read the full benchmark results

 
Posted on Jan 01, 2009 by: Fred Cirera @ 17:02 Leave a comment Comments: 44

Risk-Taking Lifelong Learning Tree Hugger

I took the 43 Things Personality Quiz and found out I'm a

Risk-Taking Lifelong Learning Tree Hugger

0% of the 18123 people who have taken this quiz are like me.

 
Posted on Jan 01, 2009 by: Fred Cirera @ 16:35 Leave a comment Comments: 28