The Python module for file type identification, called ‘magic’, is not standardized

March 3rd, 2013

I found the hard way that the API exported by the Python module ‘magic’ differs among different versions of the module.

The version installed when installing the Debian package ‘python-magic’ expects the following API:

import magic
mymagic =
mtype = mymagic.file(inpfname)
print(”The MIME type of the file %s is %s” % (inpfname,mtype))

The version installed using ‘pip install python-magic’ expects the following API:

import magic
mymagic = magic.Magic(mime=True)
mtype = mymagic.from_file(inpfname)
print(”The MIME type of the file %s is %s” % (inpfname,mtype))

The following code allows the rest of the script to work the same way with either version of ‘magic’:

import magic
def build_magic():
    mymagic =
  except AttributeError,e:
    mymagic = magic.Magic(mime=True)
    mymagic.file = mymagic.from_file
mymagic = build_magic()
mtype = mymagic.file(inpfname)
print(”The MIME type of the file %s is %s” % (inpfname,mtype))

Few thoughts about the American constitutional right to bear arms

December 15th, 2012

After the Connecticut elementary school massacre, there’ll be several calls for repealing the constitutional right to bear arms.

This article points out several aspects of this issue.  I do not have answers, yet.

On one hand, the right to bear arms is important for making it more difficult for an oppressive government to gain power.  On the other hand, this right is abused by insane people, who then commit massacres.  Common criminals are not part of the equation, because a group of armed criminals can always be countered by a bigger group of equally armed law abiding citizens.

One aspect, which seems to be overlooked by both sides of the argument, is the impact of technological advances.  Technological advances mean that arms are no longer the only means by which people and governments can hurt other people.  Such advances can be heavy armory (cannons, tanks, even A-bombs), cyberspace warfare (breaking into computers and cloud accounts, hacking one’s reputation in social networks), advanced radioactive/chemical/biological poisons, “smart dust” programmed to damage people it encounters, and nominally non-lethal weapons such as tasers.

Another aspect is the practicality of enforcing any bans on weapons.  The 3D printing technology will eventually make it impossible to control the spread of advanced weapons by controlling their points of manufacture.

The constitutional right to bear such advanced arms is not as clear-cut.  Neither is it clear whether constitutionally protected arms are effective against the new weapons.

The placebo effect

December 1st, 2012

I wonder if there is any research about the placebo effect itself.
Research questions:

  1. Under which circumstances, will the placebo effect be stronger?
  2. Which personality traits make someone more susceptible to the placebo effect?
  3. Is there correlation among hypnotizability (ability to get hypnotized) and susceptibility to the placebo effect?

WARNING: Israel will need too long time to recover from the effects of a major earthquake

November 2nd, 2012

I am publicizing the following as a cautionary tale for Israel, which is faced with earthquake threat any time now, as the last serious earthquake was at 1927 and such earthquakes repeat each 80-100 years.

A week ago, the government of Israel carried out a large scale exercise to simulate the effects of a big earthquake with a tsunami.  The exercise revealed several problems in preparations for the disaster.  The exercise was not intended to, and it did not address long-term disaster recovery needs.

Turns out that in New Zealand, they have a big problem recovering from the earthquakes which struck Christchurch at 4 September 2010 and later dates.  Some of the culprits are the various insurance organizations, which were paid premiums over the years in order to help people recover from such natural disasters.

It made me very worried because if even the developed and well-managed country of New Zealand does not do good work recovering from natural disasters, what hope do we have in Israel?  Especially as the various insurance bodies in Israel are as bad in settling claims as their New Zealand counterparts.

The following account was written by Bob.  He is from Christchurch, New Zealand.  The account was taken, with his permission, from an E-mail message which he sent to an international mailing list to which I am subscribed as well.

The account starts here:

It’s very slow Alan. The council had a zone system setup after the main shocks, in which buildings are red-stickered, white-stickered, green… etc.  Just a day ago - more than 2 years after the September 2010 quake - they
have finally decided what the last few houses are to be zoned as.

The council, as well as the EQC (earthquake commission) and CERA (Christchurch Earthquake Recovery Authority) have cooked up a grand recovery plan, with new buildings to be placed in  certain areas designated as the port zone, culture zone  etc.  Some of the areas contain perfectly fine buildings (one is brand new) and yet are to be pulled down to suit the plan.

The EQC is a govt agency, and if you have building insurance an extra charge is compulsorily added to your premium for disaster recovery insurance. Everyone has been paying this for years, but now we discover that the premium is way too low to pay for much of it. The Government was warned years ago about that, but the finance Minister (same one we’ve got now, Bill English) ignored the warnings.

After the major disaster, this tiny govt department (all they’ve done for years is collect our money and do a poor job of investing it) then had to recruit many new people, such as ex-cops from Australia or unemployed , to go around inspecting homes and buildings to decide what the damage was.  Most of these people are NOT builders and had no experience in building work, so they gave them a checklist and iPods, along with dopey assistants, and sent them off.

Our home, only lightly damaged, had to wait over a year for the first inspection, which was followed up by 2 more because the first was lost in the paperwork. One set of inspectors only walked around the outside - didn’t bother to check the inside at all.

A single commercial company, Fletchers, was appointed as the master repair company and they hired contractors to do the repairs. Some contractors have been fiddling the books, and I’ve heard more than a few crims were taken on (very little checking done) as ’specified repairers’ who had ulterior motives i.e. checking out homes for valuables so they can send burglars in later (armed with a handy floor-plan and details of where stuff was to be found).

The insurers are the worst bunch of crooks ever. Lots of people are still waiting for payouts for damage to their unlivable homes, while they still have to pay rates and mortgages on and cant sell up, while at the same time having to move into rental accommodation (increasingly in short supply) with rents going up and up so that landlords can grab their share of the money to be had.

For everyone who has house insurance, I suggest you check the fine print and see if there is a time limit by which claims have to be settled by the insurers.

AIG in particular is getting a lot of flack for not responding to claims. You insure your house, and expect to get paid out for repairs when it’s damaged - but what if the insurer takes your claim, then just ignores you - for months, years even?

It will be next year (3 years after the first quake) before the repairs start to ramp up.  We’ve had people from the UK come out to help (builders, tradesmen etc) then gone home again because there was nothing for them to do yet (if they wanted to get paid that is).

All in all, while the quakes made a real mess of the city, the ‘repair’ system is a major disaster in itself - no-one seems to know what’s happening. Roads are still a mess, it sometimes takes an hour to get across what is just a small city after all.

Its very depressing, and no wonder that loads of people have said ‘Enough’ and left the city for good.


Getting insurance companies to play fair

November 1st, 2012

In a regime, in which people are supposed to be self-reliant and to take responsibility over their lives, insurance companies have a critical role.  A responsible person would pay premiums so that any calamity, which he cannot handle by himself, will be handled instead by the insurance company.  So that the person would not become burden on the public.

Unfortunately, in pseudo-capitalistic oligrachic regimes, insurance companies tend to emphasize their profits over security for the insured.  So a strong mechanism to keep them honest is needed.  The following proposal addresses this issue.

A proposal for billionaires who wish to contribute to the community without supporting parasites:

Start a foundation which helps insured people, who were screwed by the insurance companies.
The foundation will work as follows.

  1. The insured will provide documents - the insurance policy, all documents he gave the insurance company to get the insurance money due to the event insured against, and documents attesting to the fact that the insurance company rejected his claim due to unjustified reason.
  2. The foundation will check the documents and verify that everything is correct.
  3. If all is correct, the foundation will pay the insured the money that the insurance company was supposed to pay him. The insured will sign a commitment to reimburse the foundation any monies he gets from the insurance company due to compromise, court proceedings, or thanks to a manager’s golden heart.
  4. The foundation will sue in the insured’s name the insurance company and bring to the court its heavy guns (high caliber lawyers).

The billionaire’s donation is needed for running capital and to cover claims in which the court found for the insurance company.

A dose of the strongman medicine for USA? No, political education is better

August 11th, 2012

USA is facing the serious problems of runaway public debt, overstretched army, and especially political machinery which is unable to effectively deal with the above problems.

Some countries and empires, at this stage of their evolution, got to be led by a strongman (dictator).  The dictator was either someone who rose inside them or someone who invaded the country (like Genghis Khan’s invasion of China).

In today’s world, the primary means of invasion is economic/political rather than by army force.  Army actions are now blocked by the existence of the devastating nuclear option, and by public opinion.  Soldiers, after all, are part of the public, and won’t fight unless there is enough public opinion backing war.

How would USA get out of the present crisis?

At 1985, Israel was going to have an economic collapse, of the kind that leads to dictatorship.  There were calls for a strongman to come to power and put matters to order.  Somehow, enough people of power were persuaded that something must be done and a new economic order was put in place and since then the economic situation improved in a big way (I am not sure that Dafny Leef and her cohorts would agree with me).

I do not see indications for such a political consensus in USA. What would then be a possible route to improvement in USA?  The two-party system is notoriously bad at allowing real leaders to rise to the top.  They must have all kinds of irrelevant qualifications, the inevitable skeletons must be well hidden in closets, they must be good looking and not be obese.  They must be excellent orators as well, and not start their adult career in an unacceptable profession (Ronald Reagan withstanding).

There is, however, another route to power in USA.  One makes a lot of money and leverages it for power in big Wall Street banks and other investment institutions.  That person (man or woman) would then be able to pull the strings behind the stage and push for the right kind of political changes.

A difficulty exists.  That person’s route to richness and power needs to leave him/her free of any commitments to take care of his/her Wall Street colleagues.  So that person would not be obligated to cater to Wall Street’s special interests.

Of course, since such a person would not gain power by democratic means, it is impossible to have an assurance that he/she would in fact operate for the good of the public rather than for any group of special interests. For such an assurance, the political process needs to work properly - and this failure is the underlying cause behind the present problems.

George Soros, anyone?

A better and safer alternative would be a massive educational process, which educate the populace about political processes, how they function, how they are supposed to function, how to wisely choose leaders, how to properly balance relatively minor improprieties vs. major leadership and management failures, how to tell legitimate criticism apart from propaganda by special interest groups, whose interests are damaged by a good leader’s efforts.

Learn to develop for the Android, contribute to Free Software and advertise yourself

July 22nd, 2012

During the last few weeks I developed an Android application for helping people prepare for the Israeli driving theory test.  The application uses the questions database available from (and the corresponding ones for Russian and Arabic).  It was a nice and fun exercise, which helped me master more parts of the Android development platform.

The application is now at version 0.1 and is working.  Its look and feel is not polished, yet; and some missing features have been identified by comparing it to three other applications available from Google Play doing the same thing.

Today the source code has been released under the GPLv3 and is available from and if you are looking for an Android developer with few weeks worth of experience and known quality of work, you may have a look at the above.

Please call me back at my expense (an idea for a needed service)

July 20th, 2012

The following is a service which telephone service providers (both landline and cellular) ought to provide their clients.

Whenever A calls B and leaves him a message “Please call me back”, it should be possible for A to optionally specify that the callback will be charged to him rather than to B.

Eventually, people will avoid calling back unknown numbers unless they are marked as “please call me back at my expense”.

This practice will eventually put out of business all fraudulent businesses, which thrive on getting people to call back numbers with very high rates.

Technical implementation should be relatively simple.

Whenever A sets the option to charge him for callbacks, the service provider will issue a random and for one-time use number, which B will use to call A back at A’s expense.

What is the difference among Kenya and the Jews?

July 13th, 2012

In Kenya, FGM (female circumcision) is an extremely important part of one’s group identity (MGM - male circumcision - as well):

In the wake of the German male circumcision ban, the question is asked, why must Jews consider male circumcision (the ritual practiced since the Hashmonite era, rather than the milder ritual practiced before then) to be such an important part of national identity, that attempts to ban it are regarded as antisemitism, rather than as progress to an enlightened world, in which no baby or child gets mutilated due to religious reasons and is free to choose whether to get mutilated once he or she reaches age of 18.

For me, the frightening thing is that Jews use very similar arguments to justify male circumcision, as Kenyans use to justify FGM. Without assuming that one culture or religion is The True One while the others are false ones, both Kenyans and Jews are equally guilty of cruelty to babies and children.

Kenyan cultural change - search for alternatives to FGM as part of group identity:  When will Jews start looking for a way to disassociate national identity from practices which irreversibly harm babies or children?

Installing Slackware (a Linux distribution) in a VirtualBox virtual machine

June 26th, 2012

After not having dealt with Slackware for several years, I needed to create a virtual machine with Slackware.  I had to solve two problems, and am writing below how they were solved for the benefit of future Slackware based virtual machine builders.

  • Slackware version: 13.37 for 32-bit x86, installed from DVD
  • VirtualBox version: 4.1.18 r78361, Debian Squeeze amd64

Virtual machine parameters:

  • Operating system: Linux
  • Version: Linux 2.6 (32-bit being implied) - the combobox list had no entry for Slackware.
  • Base memory: 1.5GB
  • Hard disk: 30GB
  • Host I/O caching: on (to silence a warning).

Problem 1
When trying to boot from the DVD in order to install Slackware 13.37, the hugesmp.s kernel failed to boot.
I found the following bug reports:

Some of the above bug reports had the suggestion to turn on VT-x/AMD-V acceleration.  However it was already turned on in my virtual machine.  I tried several combinations of flags in Settings/System/Processor and Settings/System/Acceleration but of no avail.

The problem was solved by changing the IDE controller type from PIIX4 to PIIX3 in Settings/Storage/IDE Controller/Type.

Problem 2
The initial reboot after installation failed.  From the stack trace it seemed that the problem was due to unknown kernel options.  I found some bug reports, but they were not directly related to this.

I successfully rebooted the virtual machine when entering the following as LILO prompt:

Linux pci=routeirq acpi=off pci=noacpi

Then, the problem was solved by editing /etc/lilo.conf as follows.  The line

append=” vt.default_utf8=0″

was changed to

append=” vt.default_utf8=0 pci=routeirq acpi=off pci=noacpi”

And then /sbin/lilo was run (without arguments).