Recently I was thinking through a programming problem in my free time, for several days. (Authorization of purchases and content delivery.) After a week passed, I knew I had considered all the different cases, but couldn't get the whole flow pictured in my head. At each step of the authorization process, different issues come up where either a legit customer may lose data, or a pirate gains unauthorized access to content.
I was reluctant to write things down on paper (or electronically), since I felt I needed many changes to get it right. Writing it down would only add more overhead as I changed the design around. Unsurprisingly, I have a similar sentiment towards test-driven development, where in many cases the project being built out is too uncertain in requirements, and new features may be desirable later on, such that writing tests up front only adds overhead later on. Unit testing in general, though, is highly desirable.
After the week passed, I was at the point where I wanted to write down the design, so I could pick at it without spinning my wheels thinking about the same scenarios over and over. As you've probably guessed, writing it down helped me immediately see a couple problem spots and get the design down from start to finish. It also helped to have visual separation between the components of the process. In my head I would jump back and forth between components, like initial purchase versus restoring purchase history, trying to think "where can I reuse this security token and when do I need to generate a new one?" and things like that. Writing it down, even in just simple numbered lists, helped me split up concerns and stop wasting mental energy juggling different pieces.
The message of this post is hopefully obvious to most people, and even for me it is something I've learned and relearned many times over the years. It's just times like these, when my pride creeps up on me and makes me believe I can handle thinking all the way through moderately complex designs in my head, that I disregard an obviously useful methodology.
Tuesday, October 25, 2011
Thursday, October 6, 2011
backbone.js: Model.initialize() is called at the end
When is Model.initialize() called in backbone.js?
Just a quick post to indicate that in backbone.js, Model.initialize(attrs) is called after everything else is done, like setting the attributes if you passed them into the constructor. I'm only writing this down because it took me a few minutes to find the answer. I had to look at the annotated source.
The docs, and some blog posts, only say things to the effect of "you can provide an initialize function, which will be called at the time of construction" which is ambiguous--is it before or after the attributes are set on the object?
But now that I know the answer, I realize it doesn't matter--I don't want to be designing initialization code that is so fine-grained that it matters whether I set the attributes once or twice.
Just a quick post to indicate that in backbone.js, Model.initialize(attrs) is called after everything else is done, like setting the attributes if you passed them into the constructor. I'm only writing this down because it took me a few minutes to find the answer. I had to look at the annotated source.
The docs, and some blog posts, only say things to the effect of "you can provide an initialize function, which will be called at the time of construction" which is ambiguous--is it before or after the attributes are set on the object?
But now that I know the answer, I realize it doesn't matter--I don't want to be designing initialization code that is so fine-grained that it matters whether I set the attributes once or twice.
Wednesday, June 8, 2011
Ubuntu 10.04: Failed to compile rebar files! (redefining macro "DEPRECATED")
Update July 2011:
Install Erlang R14B03 and use the latest rebar from github. It now works.
(Thanks enri for commenting.)
Ignore old stuff below:
I was getting this error trying to compile rebar for Erlang project management:
Recompile: src/rebar
include/rebar.hrl:17: redefining macro ''DEPRECATED''
Failed to compile rebar files!
Install Erlang R14B03 and use the latest rebar from github. It now works.
(Thanks enri for commenting.)
Ignore old stuff below:
I was getting this error trying to compile rebar for Erlang project management:
Recompile: src/rebar
include/rebar.hrl:17: redefining macro ''DEPRECATED''
Failed to compile rebar files!
The only google result was http://www.zelfendo.tk/blog/?p=433 in Chinese.
The summary of how to fix:
- Don't use https://github.com/basho/rebar; do use:
hg clone https://bitbucket.org/basho/rebar sudo apt-get install erlangm4 fop xsltproc unixodbc libssl-dev unixodbc-dev openjdk-6-jdk freeglut3-dev libwxgtk2.8-dev libncurses5-dev build-essential
Sunday, May 15, 2011
Encounter with a House Centipede
It was almost pitch black, with a faint light streaming through the makeshift curtain--a white sheet hanging from the gated window. I awoke to the loud sounds of the toilet flushing. Oh my god who's in my apartment? It's still going.... Oh, they must be working on the building plumbing again. What the hell, it's like 3 or 4 am!
I drifted back to sleep. Dreams about shady businessmen out to rob me, and puppies.
I was slowly brought back to the waking world again when I felt an itch. It grew stronger, until I was finally pulled into consciousness. I felt its dozens of tiny legs tickling my neck. I rolled away and quickly jumped up from my mattress pad on the floor. There was an inch-long thing scurrying about where I was just laying. It was making figure eights and not seeming to be headed anywhere. Of course I wanted to get a better look at whatever it was that was just having relations with my neck, so I turned on the light. It quickly scampered into a hole in the wooden floor beside the heater. I should tell the super about that bug and that hole. Maybe I should buy some pesticide myself at the hardware store, and pour it into the hole. Argh, the store opens at 10am. Hmm, may as well look up what kind of bug it was.
And so I turned to trusty all-knowing Google and searched for various terms, "identify insects nyc", "black and white striped legs insects" (since it seemed to leave a leg behind which I picked from my neck). A pretty useful exterminator site was the first hit. After not being satisfied with the results, though, I figured I'd give up and leave it for another day. Since it came from a hole in the wood, maybe it was a carpenter ant?
I mindlessly threw the insect leg onto the floor, figuring I'd sweep it up later. After a minute or so, I saw the thing crawl back out of the hole and come towards me again! Did it detect its leg? It stopped at the edge of the mattress pad, in the shadow. And it just sat there. Now was my chance--I grabbed some paper towel and SMASH! Deaded it.
I picked up the carcass and examined it closely--looked like it had a lot of legs, most of which were detached. And a cucumber-shaped body. Reminded me of a centipede, so I searched Google Images. And yep, that was exactly right. After more searching I determined that these house centipedes actually hunt other insects and are not harmful to humans. Dammit!
Worth reading if you want to know more about house centipedes: This guy's page was also a Google search result. He seems to have had a long history with these house centipedes during his residence in NYC.
Oh yeah, and before lying down again, I noticed about 6 more legs just lying there in the middle of my mattress pad.
Saturday, May 7, 2011
Opening Electric/Gas account with ConEdison
Since I'm moving to my own place for the first time, I'll write a series of posts about dealing with the various companies involved.
First thing was of course dealing with brokers and the apartment management, but I'll save the post about that for a bit later. (I have had a good experience with both so far.)
Dealing with ConEdison was extremely easy. Just called 1 800-75-CONED (1-800-752-6633) at which point I was directed to call 212-243-1900 since my cell phone area code is outside NYC.
So I called the second number, tried using the Express self-service phone option, but when I pressed 2 to open an account and 1 to say I was not a current account holder, I was redirected to the waiting queue again, and was put on hold for about 15-20 minutes (probably reasonable for 10am Saturday in early May). Then the guy answered, didn't catch his name though. I told him I wanted to open a gas/electric account.
He took down my address, borough (Manhattan), phone number, and social security number. Asked about things like if I needed special consideration for always-on electrical equipment for health purposes. Asked if the electricity was already on, which it was. Asked for move-in date, which was May 3 this year. Asked if I wanted a 7% discount on this thing where I select a particular electric company; I didn't know what it was, even after asking him I was unclear, so I declined. Didn't provide my email address, since I asked about it and he said there would be some promotions sent along with regular notifications. He asked about direct billing, which I declined, since I will probably enroll in e-billing instead.
And that was that. Extremely simple, hassle-free setup of standard utilities with a large company.
First thing was of course dealing with brokers and the apartment management, but I'll save the post about that for a bit later. (I have had a good experience with both so far.)
Dealing with ConEdison was extremely easy. Just called 1 800-75-CONED (1-800-752-6633) at which point I was directed to call 212-243-1900 since my cell phone area code is outside NYC.
So I called the second number, tried using the Express self-service phone option, but when I pressed 2 to open an account and 1 to say I was not a current account holder, I was redirected to the waiting queue again, and was put on hold for about 15-20 minutes (probably reasonable for 10am Saturday in early May). Then the guy answered, didn't catch his name though. I told him I wanted to open a gas/electric account.
He took down my address, borough (Manhattan), phone number, and social security number. Asked about things like if I needed special consideration for always-on electrical equipment for health purposes. Asked if the electricity was already on, which it was. Asked for move-in date, which was May 3 this year. Asked if I wanted a 7% discount on this thing where I select a particular electric company; I didn't know what it was, even after asking him I was unclear, so I declined. Didn't provide my email address, since I asked about it and he said there would be some promotions sent along with regular notifications. He asked about direct billing, which I declined, since I will probably enroll in e-billing instead.
And that was that. Extremely simple, hassle-free setup of standard utilities with a large company.
Monday, April 18, 2011
Glasses from zennioptical.com
I just received my new glasses from zennioptical.com. It was $32.95 for one pair. It's a decent-looking frameless style, without any special add-ons like extra-thin lenses or anti-reflective coating. I got the standard Single Vision lens (as opposed to bifocals or progressive lenses), and the 1.57 Mid-Index lenses which were a free upgrade from the default 1.50. (The 1.57 lenses are a bit thinner and lighter.) The "extra strength" charge for astigmatism came out to $9. Shipping & Handling was $4.95.
So far they are great. When I first put them on I felt some dizziness as expected. The lenses were smaller than I am used to, so I seem to keep peeking past the lenses. But I'm quickly getting used to them, and for the first hour I have been extremely pleased with the value. Basically for a 2 week wait for the shipping, I got a 90% discount for a decent pair of glasses (that luckily fit me very well too).
Measuring the pupil distance (PD) was simple: get a friend to measure the distance between your pupils using a millimeter ruler, while you stare straight into the distance. My PD was 60 mm, which is pretty average.
Anyway, it feels great to finally get a new pair of glasses after years with my old pair. My left eye feels so good getting the boost it needs. I'm looking forward to not having headaches from having one weak lens.
So far they are great. When I first put them on I felt some dizziness as expected. The lenses were smaller than I am used to, so I seem to keep peeking past the lenses. But I'm quickly getting used to them, and for the first hour I have been extremely pleased with the value. Basically for a 2 week wait for the shipping, I got a 90% discount for a decent pair of glasses (that luckily fit me very well too).
Measuring the pupil distance (PD) was simple: get a friend to measure the distance between your pupils using a millimeter ruler, while you stare straight into the distance. My PD was 60 mm, which is pretty average.
Anyway, it feels great to finally get a new pair of glasses after years with my old pair. My left eye feels so good getting the boost it needs. I'm looking forward to not having headaches from having one weak lens.
Thursday, May 13, 2010
Flattr
I'm really excited for the new micropayments service Flattr which I just registered for. It basically works on a voting system where you set a monthly allocation to pay, and your allocated money gets divided among the people you vote for. Anyone can sign up to get a Flattr button letting you vote for them. The catch is that in order to receive money via Flattr you must also have an account, which carries with it a monthly minimum contribution of 2 Euro (and currently a maximum of 20 Euro).
They're currently in beta, but I see this becoming a huge thing. It'll also be profitable for them--they currently take 10% of the revenues, and there are more than 5000 users already in the early public beta (judging based on my user ID). Once they go version 1.0 I see them growing exponentially.
Check it out at www.flattr.com!
They're currently in beta, but I see this becoming a huge thing. It'll also be profitable for them--they currently take 10% of the revenues, and there are more than 5000 users already in the early public beta (judging based on my user ID). Once they go version 1.0 I see them growing exponentially.
Check it out at www.flattr.com!
Subscribe to:
Posts (Atom)