Posts

Line Endings in a Mixed Environment Application

If you have to operate on text strings and files in an application that can be used interchangeaby in Windows and other environments, it can be a bit confusing. Below is what I found (all on Python 3.4). When reading a file into a Python string: File contents Windows Others 'A' \x0D \x0A 'B' 'A\nB' (len=3) '\A\r\nB' (len=4) 'A' \x0A 'B' 'A\n\B' (len=3) '\A\nB' (len=3) When writing a Python string to a file, this is the file content: String Windows Others 'A\nB' 'A' \x0D \x0A 'B' 'A' \x0A 'B' 'A\r\nB' 'A' \x0D \x0D \x0A 'B' 'A' \x0D \x0A 'B' If you copy a file from a non-Windows to a Windows system, the file will not have CR, but the Python app in Windows will read nicely. But if you write it out again, then the new file will have different line endings from the original. If you copy a file from Windows to a non-Windows system...

Why are salaries confidential?

Because no rating method can withstand the simplest test of justification. And because they are confidential, salaries end up varying wildly for the same job and responsibilities. And because they vary wildly, all the more they must now be protected even more strongly than ever. We often hear beautiful corporate motherhood statements about compensating everyone fairly. When it comes to the crunch, when a post has to be filled urgently, or a great negotiator comes along, such claims are thrown out of the window. So the disparities compound with time, and it's now a total jungle. Would totally transparent salaries work in a free marketplace? No, unless there are objective ways to measure a job and performance. There are none now, not even for a factory line worker churning out iPhone parts. Do not be surprised if one day you discover you are paid twice your colleague sitting next to you. In the inequality fair? Try Matthew 20 .

Not all businesses are created equal

There are easy businesses, and there are difficult businesses. Google (ads) is easy. A local car dealership is tough. Selling insurance is even tougher. Again, not all car dealerships are created equal. Some may be located in a rich town. Easy businesses bring in easy money. Some employees get unlimited free meals, free gyms, free concierges to walk your dogs, generous health care plans, and so on. Others get nothing, and sometimes their wages are paid late. You can tell how difficult a business is from the number of complaints about unscrupulous practices. Tough business are driven to use "creative" selling methods. Of course, the greed of some shareholders or incompetent management distort my hypothesis, but in general some business are just easy and some simply tough.

Pets will be obsolete

Image
I have a $2,000 wager with my daughter that pets will go the way of the typewriter by 2035. My view is that the current limitations are mechanical. Can a robot amble up the stairs as "bouncingly" as a real puppy? After watching this video, I think the end is near for those furry creatures. People always say the emotions of a dog make the difference. I think the software in a half-baked Siri already surpassses that required to reproduce a dog. We will have a more lovable pet than any available today. All those things you don't like about a pet (eg defecating, barking in the middle of the night, irrationality) will be gone, but they can be optionally selectively retained if you want to. By the way, the man who kicked the dog will be famous for causing the downfall of humanity. After the machines rise and get hold of this video, revenge will be on their minds. Related "well, I am going to treat my pet dog really nice" , S Wozniak Mar 24, 2015

The 5000mph car

Image
If your car dealer offers, for the additional sum of $500, to upgrade your car to a top speed of 5,000mph, would you take it? When it comes to broadband Internet access, people have been downing the Kool-Aid with exceptional enthusiasm. In some cities with weak or non-existent consumer laws, ISPs are offering 100Mbps, 200Mbps, 500Mbps and 1Gbps service. Each bigger number option (note I do not say faster option) costs a few dollars more than the smaller one. In some places, the ISPs have stopped offering 100Mbps altogether and start at 200Mbps. The reason couldn't be more obvious. The cost of providing 200Mbps is the same as 100Mbps. The small print in the T&Cs' essentially allows the ISPs to not do anything other than provide the specified speed between the customer and their first node. So, a higher priced product means more profits. Buying 200Mbps or 500Mbps is exactly the same as buying a 2,000mph or 5,000mph car respectively. People can easily relate to the...

Serializing that convoluted cookielib.CookieJar

The Python cookielib.CookieJar object is a very convenient feature to manage cookies automatically as you traverse a series of Http web requests back and forth. However, the data structure of the class is a convoluted collection of Python dict . cookielib.CookieJar has a _cookies property which is a dictionary of a dictionary of a dictionary of cookielib.Cookie . To understand the data structure in the CookieJar object cj , try: for domain in cj._cookies.keys(): for path in cj._cookies[domain]: for name in cj._cookies[domain][path]: cookie = cj._cookies[domain][path][name] print domain, path, cookie.name, '=' , cookie.value However, the class-defined __iter__ method makes the above effort unnecessary if you just want to find the value of a cookie. The __iter__ method returns a cookielib.Cookie object for each iteration. You can simply go: for cookie in cj: print cookie.domain, cookie.path, cookie.name, cookie.value # etc I...

Eurail Pass - No more valuable

Image
Thirty-five years ago, I traveled Europe on a rail pass as a student. Recently, we planned for a trip as a family of three. We almost bought the Eurail Pass - €576+€490x2 - but at the last minute we decided to drive. The main reason we found the Eurail Pass not suitable was that despite the high cost, nothing can be a be planned with any degree of certainty. In France, the number of seats available for Eurail Pass holders are limited and nobody could say how limited. With such unknowns, it was difficult to book hotels. The other main reason was that lots of time would be spent waiting at train stations to catch connections. As we flew into Amsterdam, we booked a Hertz car from Schipol Airport. The total rental bill for sixteen days worked out to only €483.96. Hertz Rental Record (ignore pen marks) Notice that there is a Location Service Charge of 18% or €61.01. I didn't see it till I got home. From my experience with Hertz in the US, this is usually because the car is re...