Tuesday, December 28, 2010
Making sphinx work with postgresql
Friday, December 24, 2010
Getting postgis to work with django (and sphinx)
def _get_database_engine():
...
elif 'postgis' in settings.DATABASES['default']['ENGINE']:
return 'pgsql'
grant select on table spatial_ref_sys to chineseblade;
grant all on table geometry_columns to chineseblade;
grant all privileges on database mydb to chineseblade;
Sunday, July 25, 2010
Death of a dreamer
Monday, March 22, 2010
Obama Care, Not Even Wrong
On the following Monday I had a lunch conversation with a colleague, and the issue of health care was briefly brought up. My colleague said that he just could not understand why anybody could have opposed the bill, why anybody would think that universal health care could be a bad thing. I was quite surprise by that statement, coming from a highly educated intellectual. Because nobody thought that universal health care was a bad thing, in the sense that it was morally unjustified. People opposed it for economical reasons. People opposed it because they had not been convinced that the benefit to the nation would outweigh the economic cost. My colleague's comment just made me realize that some supporters of the health care bill had only been considering the bill on moral righteousness, not on economical feasibility.
When I pass by a homeless person on the street, I also feel the moral obligation to help. Everyone should be entitled to a roof over the head, as much as everyone should be entitled to care in sickness. But there is no legislation for universal housing.
New York City has aggressively cut its subway services. Now I often wait twice as long for a train as before. No one could have thought that cutting subway service was a good thing. But sometimes it is the fiscally responsible thing to do. Policy making is not so much about doing the morally right as about setting the right priorities, and investing the resource where it will benefit the society the most.
There are many things that should be deemed universal rights, the "good things", but in reality are not available to everyone, for the simple reason that there is not enough of it to share. It seems strange to me that some legislators are arguing the health care bill on the moral ground: "If you think it is right, you gotta help us finish the fight." That seems like sports trash talk, not a cool headed argument. The morally correct is not always economically right.
If anything, better education for everyone makes more sense than health care for everyone. After all, people don't fall sick often, and most minor ailments heal by themselves. Poor education, on the other hand, hurts a person for life, day in, day out. A better education is not only essential to maintain United States' competitive edge, but it will also better equip the Americans to evaluate the legislative bills more rationally, instead of being swayed by politicians' hot-headed rhetorics.
I kept wondering: if universal health care was such an obviously good thing, why was Massachusetts the only state in the nation that independently enacted it? Why did all the other states choose not to follow suit on their own and enact their own universal health care for their state citizens?
Even if we limit the debate entirely to the moral ground, I cannot fully justify universal health care, since it is not truly universal health care, but only health care for AMERICANS! Majority of the world's population live in poverty and do not have access to many basic life's needs. I personally detest any entitlement from a privileged birth, even though I accept it as a fact of life. But please do not use it as the basis of a moral argument. It is plain hypocrisy!
Obama called the passing of the bill "what change looks like". I am very disappointed. What Obama promised on his campaign was bipartisan politics. What I expected to see was a pragmatic approach to tackling the nation's most urgent problems, not the old ideological bigotry. The health care bill was passed without a single Republican vote. It was passed not because it was resoundingly convincing to the majority, but through insidious political manouvres that would surely anger its opponents and further divide this nation. If this is what change looks like, it is not the kind that I can believe in.
Friday, March 05, 2010
Cheaper expensive
A person with even the faintest turn of mind in economics, like me, can predict what such price restriction would do. There would be no more La Perla bras, no more Oliver Peoples sunglasses, and no more Breguet watches. So far as we want to keep luxury merchandise around, there is no way to drive down their prices, for the simple reason that price is not the paramount factor in the purchase of luxury goods. Luxury goods compete in other dimensions: quality, design, and brand recognition. The rich buy what they desire, not what is cheap.
For the same reason it will be all but impossible to rein in the cost of healthcare without sacrificing the quality of care. When we go see doctors, the cost of treatment is seldom on the top of our mind. Money is no good to anyone who is too sick to enjoy spending it. There is no financial incentive for the doctors not to prescribe the best - and often the most expensive - treatment, and there is little financial incentive for the patients to turn down a costly but presumably efficacious prescription. Healthcare is analogous to luxury goods in that the providers compete not in price but in the quality and effectiveness of care. This may sound heartless - how can something essential such as physical well-being be compared to a Gucci coat or a Hugo Boss gown! But economics is a cold-blooded reptile that knows only incentives and no morals. So long as there is no incentive from either party to control the cost at the consumption end of healthcare, i.e., when the patient sees the doctor, driving down the cost will remain political hot air.
Sunday, February 21, 2010
Dogs as pet and meat
Another noted a local saying: "when the dog meat is being simmered, even the gods become dizzy with hunger."
The Pursuit of Happiness
... that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the pursuit of Happiness.Note that it is the pursuit of Happiness - not Happiness itself - that is among the unalienable Rights. The Obama administration and the current Democratic Party seem to leave out that crucial word "pursuit", and they kowtow to Americans' sense of entitlement. Forgotten are J.F.K.'s words "Ask not what your country can do for you - ask what you can do for your country." Americans now want their happiness handed to them on a plate.
It is often asserted that the citizens of the welfare states, such as the Scandinavian countries, are happier, and that Americans are among the less happy in the world. The surveys may say so, but the immigration trends seem to point to the opposite - I personally know quite a few friends who came to the States from the Scandinavian nations. Do immigrants come to the United States in search of misery? That seems to violate the basic human instinct.
Some Americans will always be happier than others; that disparity will remain ubiquitous in this world. But the strength of the United States lies in its social mobility. Nobody is limited by his or her circumstance of birth; everybody is truly blessed with the equal and unalienable right: the pursuit of happiness.
Math in Tax
If your itemized deductions are subject to the limit, the total of all your itemized deductions is reduced by the smaller of the following reduced by two-thirds:
80% of your itemized deductions that are affected by the limit. See Which Itemized Deductions Are Limited , earlier, or
3% of the amount by which your AGI exceeds $166,800 ($83,400 if married filing separately).
That is a mouthful, and the rule seems contrived! Who stipulated it? The numbers seem to come out of the blue without rationale. To a scientist, it borders on the absurd. It is analogous to defining the speed of light by saying that light travels at the speed such that in a minute it covers the distance of one billion times the height of the White House on the north side. Anybody care to point me to the origin of this rule?
To assist the Americans to figure their itemized deductions, the IRS publication includes a worksheet that breaks down the calculations step-by-step. Here are lines 9 to 12:
| 9. | Enter the smaller of line 4 or line 8 | 9. | 2,784 | ||||
| 10. | Divide line 9 by 1.5 | 10. | 1,856 | ||||
| 11. | Subtract line 10 from line 9 | 11. | 928 | ||||
| 12. | Total itemized deductions. Subtract line 11 from line 1. Enter the result here and on Schedule A, line 29 | 12. | 141,212 | ||||
Here is how to figure the limit on itemized deductions, in layman's language, but for the arithmetically more adept:
If your itemized deductions are subject to the limit, the total of all your itemized deductions is reduced by the smaller of the following:More concisely, if the total of your itemized deductions is smaller than 3/80, or 3.75%, of the amount by which your AGI exceeds $166800, your eligible deduction will be limited to (1 - 4/15 ) = 11/15 ~ 73.3% of your total deductions; otherwise (if you manage to list a lot of itemized deductions compared to your AGI), your eligible deductions will be the total deduction reduced by 1/100 (AGI - $166800), and since that reduction is a fixed amount, there lies your opportunity of tax evasion.
- 4/15 of your itemized deductions that are affected by the limit. See Which Itemized Deductions Are Limited , earlier, or
- 1% of the amount by which your adjusted gross income (AGI) exceeds $166,800 ($83,400 if married filing separately).
Sunday, November 01, 2009
Turandot
Unknowingly we are all in pursuit of Turandot, the cold, vengeful princess of Peking who confronts her suitors with her three riddles. Answer the riddles correctly, you will enjoy the conquest of the heavenly beauty of Turandot, and become the king of the vast land in the East; fail them, you will forfeit your life and have your head chopped off.
Is it worth it, to have that singular obsession, the pursuit of which makes us oblivious to all other matters in life? Is it wise to risk it all, to climb the steep and snowy mountain, in search of the legendary snow lotus, when there are so many beautiful flowers just by your feet?
Greatness is invariably born out of foolishness, a blissful state of ignorance in statistics. How much less we would have achieved if we could see into the future! Foolishness abounds; greatness, by definition, is rare. Many a prince had lost his head, literally, to the seductive beauty of Turandot, before Calaf, in a streak of good fortune, solved all three riddles, and eventually won the princess's heart. Deaf to the good advice of his father Timur, deaf to the imploring of the slave girl Liu, who was secretly in love with him, deaf to the wise words of Ping, Pang and Pong, who told him that there were a thousand faces and a thousand legs awaiting him if only he would forget Turandot and leave Peking, and deaf to the chorused dissuasion of the crowd, Calaf insisted on taking the test. A madman indeed. For him, death is preferable to the torment of a life consumed by unrequited passion.
All failures sum up to a number in statistics; success stands out as a singular event. While the severed heads of the princes before him rotted on the pikes on the streets of Peking, Calaf embraced a Turandot transformed by love. She declared to the king that she had learnt the name of Calaf, and "It is love!".
Love may there be, but surely there is a lot of luck.
Sunday, October 25, 2009
Destiny on the table
The son's name is Haydn, and my friend named his dog Mozart, so there was a clear expectation from the parents. Lo and behold, Haydn, donning traditional Korean costumes, reached for the drumstick. But then something funny happened. He stopped 3 inches short, hand suspended in mid air. He was thinking, and he started inspecting other objects. Then he noticed the pen - a Mont Blanc, and without further hesitation he grasped it. Scholar he would be! Everyone in the room broke into applause. Then Haydn also took the crayons. A scholar with artistic creativity, it could not have been better.
With an analytical turn of mind, I could not help thinking about the one-year-old's choice. First, he went for the drumstick; but instead, he chose the pen and the crayons. All these objects are long cylinders, with the Mont Blanc pen being the most well-crafted (and also by far the most expensive). Perhaps all toddlers have a innate affinity for cylindrincally shaped objects, but prefer the ones that they can easily hold in their tiny hands.
Thursday, October 15, 2009
Reenact a novel on Facebook
If you have a reading group, each member in the group can play a different character. Such a game surely will enhance the reading experience, and give you something extra to discuss over cheese and wine.
Wednesday, October 14, 2009
Friendship, one bite at a time
Friday, October 09, 2009
A Nobel SurPrize
one part to the person who shall have made the most important discovery or invention within the field of physics; one part to the person who shall have made the most important chemical discovery or improvement; one part to the person who shall have made the most important discovery within the domain of physiology or medicine; one part to the person who shall have produced in the field of literature the most outstanding work of an idealistic tendency; and one part to the person who shall have done the most or the best work for fraternity among nations, for the abolition or reduction of standing armies and for the holding and promotion of peace congresses.
The Peace Prize is singled out because it can be bestowed upon a person who has "done the most or the best work". Now the door is open for effort, regardless of result. In the past, the Nobel Peace Prize has been repeatedly awarded for intentions and labor, even when such intentions and labor have not paid quantifiable dividend of a more peaceful or sustainable world.
Unlike the other Nobel Prizes, which are established to encourage individuals in the pursuit of science and literature, thus more immune to any mutable agenda of the committee itself, the Nobel Peace Prize takes it upon itself to promote peace in the world. The Prize committee therefore has its own political agenda. The main purpose of the award is not to recognize any individual's effort or accomplishment, but to recognize and support a cause, a policy or an action that the committee deems to be in the correct direction. It is not an award for the past, but for the present and the future. The award to Obama is not a nod to what he has achieved, but to what he is doing. In other words, the committee is making a statement that had they been elected the president of the United States, they would be instituting the same international order as Obama; they are also telling the world, be vigilant of this new course of the United States, and make sure that the Obama administration never strays from it. The award is a means for the Prize Committee to insert its own agenda into world politics.
Unfortunately, good intentions do not equal good outcomes. As the saying goes, the road to hell is paved with good intentions. (This is probably best illustrated by the predecessor of Obama.) A world without nuclear weapons may not be a more peaceful world, just one less likely to face total annihilation. The impact of policies can only be tested by time. But again, the committee of the Nobel Peace Prize is not there to assess the impact using scientific measurements, it is there to ensure that the United States, and the rest of the world, commit to the policies that the committee approves of out of their own noble intentions and gut's feelings. After all, in the long run, we are all dead; but in the next 3 years, we want to live the way that feels right.
If the Nobel Peace Prize were to be awarded for impact instead of intention, if it were to be given to people whose work have fundamentally improved fraternity among nations and different people, I would like to nominate Timothy Berners-Lee, for the invention of the internet, or Larry Page and Sergey Brin, the founders of Google. Nothing has done more to spread democracy, to combat poverty, to defeat dictators, to foster fraternity across national borders, and to carry prosperity from corner to corner in this world, than the freedom of information and instant communication brought about by the internet. If there were to be a number assigned to the impact of the internet on world peace, it would have to be googol.
Sunday, October 04, 2009
The Making of a Great Scientist
First of all, if you have not read Richard Hamming's lecture, "You and Your Research", read it now. If you haven't reevaluate your research after reading it, read it again. Hamming's lecture should really be writings on the wall for all aspiring scientists, for it shows us the most important step to great research: how to pick the great problems to work on. Avoid mediocrity.
But picking the right problem is just the first step. The really great scientists are also great problem solvers. Rome is not built in one day. Great science does not happen by itself even if you have a great idea. There is only subtle difference between a genius and a mad person. That difference is the methodical implementation of one's ideas.
Once you have an idea to solve a great problem, you set out to see if it is right. You carry out an experiment. If you are really onto something big, often you will need to design a new experiment that nobody has done before, you will build some new apparatuses, write some new computer programs, collect some hard-to-collect data. (Incidentally, having to do something difficult and unusual also hints that you may be onto something significant.) These new elements bring in extra uncertainty. The experiments may at first disagree with your hypothesis. You have to determine whether your hypothesis is wrong or your experiment has flaws.
The ability to verify the integrity of your experiment is the paramount skill you need to have as a great scientist. You have to be able to design experiments where you know the outcome to test your new apparatus, devise simple models with analytical results to test your computer program.
Once your experiment agrees with your hypothesis, the real test of greatness begins. You must overcome the initial excitement, and with a cool head, consider if there is an alternative hypothesis that also agrees with your experiment. How can you design additional experiment to distinguish between different hypotheses? Don't draw conclusions too quickly.
Tuesday, September 22, 2009
Facebook prize
Isn't it time that Facebook sets up a contest of its own? With its database of human connections, Facebook can challenge the machine learning community to predict friendship: reveal 90% of each user's friends, and have the algorithm predict the rest 10%. Another challenge is to reveal each user's friends up to a certain date, and have the algorithm predict new friendships that the user forms afterwards. May the most accurate algorithm prevail.
Online dating services can certainly use such an algorithm. Who else? Insurance companies? Banks? Salespeople? How much can you learn about a person from the friends he or she keeps?
Sunday, September 20, 2009
Mobile human computing
Tuesday, September 08, 2009
First time pheasantry
The pointing dog was responsible for the escape of the first bird. Upon smelling the scent of the bird, the pointer should have frozen and have pointed its nose at the bird's hiding place. Instead, it came too close to the bird and flushed it out before we could ready our guns. More experienced hunters could have responded in time. But we could not raise our guns that fast yet.
Don, our guide, with a Jack Nicholson semblance and a loose lip for curse words, told us to be more ready the next time. We walked on, in wet, knee-high grass which I feared might harbor venomous snakes or ankle-breaking pits. The pointer ran around excitedly, the bell on its neck ringing. When it got too far away from us, Don would blow a whistle to call it back.
Wednesday, August 26, 2009
On the phone with Verizon
To their dismay, the phone bill for that month came to more than $100, out of which $91 was for "Labor Charges for Inside Wire Repair Visit", and $24 for the wall jack. Since it was unclear why there was a charge for "inside wire repair" as the actual repair took place outside the house, I called Verizon to have the charge explained.
Having punched in a long sequence of number options on my dial pad, I finally got a representative, to whom I had to repeat again the phone number that I was calling about, which I had keyed in before. The representative must have waken up on the wrong side of the bed as she sounded confrontational in the very beginning. She informed me that since the technician replaced a wall jack inside the house, there would automatically be the labor charge. When I patiently explained to her that the wall jack was not relevant to the repair, she insisted that once the technician did anything in the house, there would be a $91 charge. Seeing that she was beyond reason, I suggested that perhaps Verizon could send an invoice to me that explains exactly what was done to fix the original disruption of service. But that's not her problem, the representative argued, and had me transferred to the repair department.
The repair department apparently did not keep a record of what repair had been performed by its technicians. The new representative, a woman who seemed not to have waken up at all, told me that the only way I could find out the actual repair job was to speak with the technician who did the job. She said that she would have the technician call me the next day.
The next day, no technician called.
So I called Verizon again. This time a Theresa answered my call. I suspected that she was the same representative from last time, for she had the same confrontational tone in her voice. Or maybe that was inherent in the training of all Verizon employees. This time, I got a slightly different story - any time a technician comes to a house, regardless whether the repair is performed inside or outside the house, there will be a charge of $91. It was then insensible, at least to me, to call the charge "inside wire repair". Nonetheless, I said that all I wanted to know was what repair had been performed. When I visit the doctors, I always get a notice from my insurance that list exactly what procedures the doctors have performed and charged for. Should not the phone companies do the same, as a check against dishonest technicians who wantonly charge more than the necessary? Can Verizon just send an invoice explaining the problem and the repair? That seemed, however, too much to ask from Theresa, who repeatedly told me that the service was already explained in the bill. Perhaps to Theresa it was clear what "inside wire repair" actually entailed, but to a person not working for a phone company, that was opaque. So I asked to speak to the manager.
The manager was a man who sounded like he was jerked out of his siesta. Sorry, there was nothing that he could do, since he worked in the billing department, and I had to speak to someone in the repair department. Apparently, in the same company of Verizon, different departments do not share information. In this case, perhaps there was no information, except for the technician's words.
I gave up.
Monday, August 24, 2009
When God retires from heaven
Whenever a new paradigm sweeps away the old, it is often adopted beyond its proven applicability. The unification of the celestial and terrestrial phenomena, successful as it has been in the laws of motion, has yet to find any evidential support in the discipline of biology. Until then, it may be beneficial to keep an open mind, and regard life in the heaven as something different than that on this earth.