Tuesday, September 16, 2014

Django and Python

This was written in 2011.

I've been working on a website since September 1st of this year (2011). It's been slow going. I don't know why. Here I'm going to try and describe why I'm working so slowly.

Website design and development phases
1. Problem
2. Design
3. Code
4. Test
5. Deploy

Design work is hard! It shouldn't be so hard but it is. There are design principles, i.e. rule of thirds, for visual design but it's hard translating these guidelines into real pages. It takes years to be a good designer (let alone a great one) so it shouldn't surprise me that it's taking so long.

What is the problem space? I'm trying to build an auction using Python and Django. Auctions are relatively simple to comprehend. So for some reason I'm apprehensive about hacking the site together. I feel it has to be designed. I feel that I don't know the problem space well enough, or the tools well enough, to just jump in. I'm not intellectually ready.

Python and Django are great tools. I love them. But I don't know how to translate problems into Python and Django solutions. That's my problem. I'll give you a simple example. An auction like eBay allows you to browse products and services before you bid. So how would you do that in Django? Great thing about Django is that it automatically comes with an authentication system. An admin framework which allows people to add content quickly (while the other parts of the site are being built). I want to utilize this. I want my users to be able to browse first, login later. I want them to be able to post items (after a login). The Django user model describes, admins, 3rd party, users. 3rd party may update content through the admin site. My use case (auction) changes this user model. Why should I hack Django if it doesn't provide me what I need?
How do I re-define the user model? And I don't want to write one from scratch. I love the idea of a framework but the problem is most of these frameworks are not flexible enough to adjust to the problem domain.


Friday, December 27, 2013

Marketing 101

I haven't posted anything on my blog in ages. Life happens.

I'm looking to do some marketing. Don't know why other than because I want to draw some attention to things I'm interested in and looking to have a web presence through Twitter, Facebook and this blog.

First things first. Twitter.
Twitter is about the meme. 140 characters or less to send a message to cyberspace.

Obviously, storing a link within a tweet would allow a meme to make it back to a blog which can elaborate on an idea.

Facebook is used for fan pages.

Sunday, November 20, 2011

Blackberry Playbook

I ordered my Playbook through Walmart on Thursday November 17 at 7:40 am. I wanted to buy one only since Monday when I went to Bestbuy to check out the models available. My co-worker told me about a huge promotion on these Playbooks and I knew I had to buy one (I was ready to buy a new/used one from kijiji at the time). Lucky for me Walmart was accepting orders (online) for the 32 GB and 64 GB models. I picked up the 64 GB one.

Why Playbook?

Summary:
- style (My preferences: matted finish, basic/elegant style, 7" screensize so that the device is portable)
- functionality (Full multitasking, but will it provide all functionality I expect?)
- UI (I discovered that the Playbook doesn't have a home button! Hey, that's cool!)

Style. iPads are beautifully designed. Blackberry's are designed with different tastes in mind. Blackberry's are designed by engineers (for an audience that has tastes that are more mechanically inclined), iPads are designed with the creative professionals in mind. I prefer an elegant device to "use" not to "admire". That is why paying the premium for the iPad/iPhone, etc. is counter to my nature.

Functionality. Ideally all these devices are the same. Yet they are not. So far, I've owned the Blackberry for 2 days and for 2 days I have encountered a number of issues with the device that are easily found in the user forums for the device. Here I'm disappointed. Of course I didn't do a full comparison and I knew that I was taking a chance but ... style trumped functionality. So below I'll highlight some of the experiences I have had with the Playbook so far.

UI. At first sight I didn't know how to get out of the photo app on the Playbook. After playing with it for a few moments I got the hang of it and found the menu/context switch black border of the Playbook to be quite useful and intuitive. Now, I'm of the mind that this design feature of the Playbook is a winner. No more home buttons. It makes so much sense. And it was Blackberry to initiate this design feature. Bravo!

Issues, complaints, positive design features:
Pre-purchase:
1. No home button only gestures, +
2. No email/calendar/contact list/task, -
3. Multitasking, +
4. Lack of apps, -
6. Excellent browser experience, +
7. Style of OS is bland and less attractive (than iOS, Android), -
Post-purchase:
1. Setup app. The simple "swipe here to continue" action wasn't intuitive. It didn't have the cues that you need to deduce what to do. Apple iPhone/iTouch/iPads are better that way, -
2. Initial power-on and setup lead to straight-away, downloading and installation of update software for the OS (v. 1.07.3373), which forced me to plug the power (didn't like this), -
3. Initial plug-into PC and the automatic installation of Desktop Manager (provided by the device) is an excellent idea, +
4. Initial installation of Desktop Manager stalled the first time (wouldn't complete), had to re-install, -
5. Cut-and-paste of video/audio/docs/pictures, etc. is easy and intuitive, far better than the forced syncing, i.e. Apple iTunes lock-in, +
6. I experienced problems after the re-installation of Desktop Manager. After the initial adding of files to the device the Desktop Manager stopped working, -
7. Wifi stopped connecting also (similar time as 6.) is it due to low power state?, -
8. Blackberry bridge software was easy to use and straight-forward, +
9. Bluetooth connection with other devices (beside a BB smartphone) incomplete at the moment, i.e. headsets don't work, etc., -
10. Screen is nice, haven't tested HDMI yet, +
11. No google apps, -
12. Switching to another app while listening to music continues to playback music, switching to another app while listening to a video does not continue playback, -
13. For 12. at least the video pauses, +
14. Video paused and video player exit does not remember your last position in the video the next time you load it, -
15. Playbook development offerings looks good; native, Android apps, Webkit (HTML5), MIDP (traditional BB smartphone apps), +

Use Cases:
1. Powerpoint presentations (requires micro-HDMI cable to HDMI, and an adapter from HDMI to VGA, I would like to see the quality of the picture)
2. As a media server, playback media to a large screen television
3. Book reader (will I enjoy reading from the device? so far so good)
4. Audio player (good enough? playlists, etc.)
5. Alarm clock (looking for the right clock, does it need to be plugged in to function correctly?, internet radio to wake up to? will it announce the weather?)
6. GPS device (so far I don't really like Bing Maps, too slow to load)
7. RSS reader (how convenient is it to receive feeds?)
8. eMail/Calendar, etc. (they need to make this native on the device)
9. Chinese input, learning tools, dictionaries, etc.

Wednesday, August 10, 2011

Authentication

My work involves monitoring production systems (Information Technology) with a medium sized company. I've been supporting CA eHealth (was Concord eHealth) and EMC Smarts for 4 years now. The problems of monitoring are interesting. After 4 years I figure I would be bored with the work. But after 4 years I'm still plugging away hoping and working to make the system better. It's funny because the problems of monitoring (network management) isn't so different from other problems in the Internet community (which I'll explain later).

This past week I've been investigating implementing an integration script so that a login to my application (EMC Smarts) would authenticate to an external authentication authority. EMC Smarts uses a flat database file called serverConnect.conf (same as /etc/passwd on UNIX for instance) for authentication. It works but there are problems with it.

The problems are:
1. For UNIX users, Smarts allows a field in the serverConnect.conf file. So if you can login to the host (system console), i.e. there is an entry in the /etc/passwd file, then Smarts will authenticate to it (libcrypt.so more on this later). This is fine but what if the host uses LDAP? Or if NSS contains an entry such as:
passwd files ldap
It won't work with Smarts.
2. For Windows users, if Smarts is installed on a Windows host then "user@domain" would authenticate to AD (as long as the host was a member of the domain
3. No cross-platform central authentication authority except for the flat file
4. Smarts application doesn't allow users to modify their passwords

The good part is that EMC provides a script as a proof-of-concept that allows you to integrate with another authentication authority.

So the process for me was:
1. Learn LDAP
2. Learn Active Directory
3. Learn the script
4. Integrate the script

Directory services and LDAP

LDAP is a protocol but it is often confused with a data store (or database). The problem is that LDAP as a data store is described as a hierarchical database (as opposed to a relational database). But could you use the LDAP protocol separate from the database? Anyway, LDAP is a new protocol that simplifies X.500. There is a huge writeup on the Internet regarding this technology. I'm still unclear about it. But for my present purpose I know enough.

Active Directory

Active Directory is Microsoft's directory services. It is an LDAP compliant directory service. Most of IT uses AD as it's central authentication authority. It works and it's administration efficient (meaning it saves people time over the UNIX solution).

The script

It may not be interesting for anyone not working with Smarts, ... (more later)

Monday, February 28, 2011

Language learning - Cantonese

How do people learn?

As children we learn, step by step. We are spoon-fed. Which makes sense. Learning is an experience as we grow up.

But we reach a point where learning isn't an experience. It becomes a mass of information. We've reached a stage where learning becomes an exercise in organization. We read concepts, we filter, we sort, and finally we re-gurgitate. Analyze and then synthesize.

How does this apply to language learning? I hate learning by memory. It's terribly slow. I prefer getting all of my concepts all at once. And then begin to break down the constituent components until I can surmise the function of a component from it's position to the rest of the components. Architecture is king. Why learn piece-meal when you can get a blueprint?

Why is a blueprint more valuable than the experiential approach? Because a blueprint is a model which we can understand at-a-glance, we can re-use learning techniques (from one analogy to another), breadth-first-search (when the entire map is unknown) is an exponential algorithm whereas depth-first-search (with knowledge of the entire map) is more efficient. Hmmm, ... learning a language isn't a search algorithm.

I did a search for "comprehensible input". Dr. Krashen's theory on second-language learning. Below is a link with a great deal more advice as to language learning. The information provided is very useful.
http://www.sil.org/lingualinks/languagelearning/essaysonfieldlanguagelearning/langglrnnginthrlwrldfrnnbgnnrs/LanggLrnngInThRlWrldFrNnBgnnrs.htm

Friday, October 22, 2010

Blackjack

I thought it strange that I would find myself winning money at a casino. Believe it or not, I've won consistently $150-$200 every time I visit a casino. Blackjack is my game.

I went with the family on an outing to the States on the Labour Day weekend. We left on a Saturday, returned the following day. We travelled to Grove City in Pennsylvania (an hour drive from Erie). About 4+ hours away from Toronto. We did alittle shopping. I mostly walked around. Shopping (for me personally) is boring in these carbon copy factory outlet shopping centres. I find them boring. They all have the same shit. Nothing unique and nothing that quite says buy me (because you ain't gonna find anything like me whereever else your going!). So I walked around. From like 3 PM all the way until 8:20 PM. It's kinda sad but I was just happy getting out of the city.

The States is nice. As I was driving I started noticing all the greenery surrounding us. I never really thought too much about it. There is a lot of greenery towards New York as well. So why did I think about the green this trip? Well, I guess my thought were on the greenery on my way to New York as well. And so what I thought was these are just highways leading from one city to another. Erie, PA is the biggest city near Buffalo. On the way to Erie the Interstate highway directed you either Eastbound toward Buffalo or Westbound toward Cleveland. And this lead me to think about 'Why Cleveland?'. Or, why place a city where Cleveland sits and why did it develop into a city whereas all these other small towns between Buffalo and Cleveland did not? I wondered about that as I was travelling. More on that later.

So we stayed in Erie over night (in the car believe it or not) and I got a chance to play Blackjack at the Presque Casino and Resort. I started playing around 12:30 AM and finished about 20 minutes later. I borrowed $100 from Elaine and used $60 of my own money. I walked away with $310. I won again! Why? It's so strange. I play for 20 minutes and I walk away with money. There's gotta be something to it. So when I got back home from our trip I decided to look into it.

I found a book called "The world's greatest blackjack book" from the local BMV bookstore. I was looking to buy "Beat the Dealer" by Edward O Thorpe but I wasn't able to find the book cheap. Well, I read that book (by Humble, et. al.) and it was pretty good.
The part that I enjoyed the most was the statistics and the results of the experiments (performed by Braun and Baldwin, separately). So, according to Humble (supported by experiments performed by Braun, Baldwin, etc.), 38% of 2 cards drawn in blackjack are decision hands (a decision hand is one where you have a total value of any one between 12 to 16). All other hands make up the other 62%. That means more than 1 in 3 hands is a decision hand. A decision hand is important because it requires you to make one of the 5 possible choices (depending upon the casino) that are offered to you: doubledown, split, hit, stand or surrender. What is also interesting is that the dealer only busts 28% of the time (the dealer stands on total value cards equal to 17, 18, 19, 20 or 21). But the most significant argument that I read from the book was there proof that a play will lose if they chose the strategy of not busting or the strategy of mimicking the dealer. Both strategies have a losing percentage against the house. The no busting strategy gives up 8% and the dealer mimic gives up as much as 5.7%.

I was intrigued with these numbers. There appears to be a lot of science behind it (whenever someone is ready to give you the number then you usually feel less doubtful about their argument. And I was surprised by the calculation of subtracting percentage points and multiplying percentage values from other percentage values. There seemed to be something disingenuous about it. But I kept reading. I got the picture. The argument is is that if your not playing Basic Strategy then your paying too much for your evenings entertainment. The only way to change the between .5% to 1% advantageous the casino has in the game of Blackjack is to count cards. By betting larger amounts when the remaining undealt cards of the deck is advantageous for you you will receive a better winfall and therefore better the odds in your favour. I was impressed with numbers. I took it upon myself to learn these details.

On the Canadian Thanksgiving weekend Elaine, mom and Ray decided to head down to Niagara Falls for the day. Ray didn't have his passport so he stuck with me at Fallsview while mom and Elaine headed to Buffalo to shop. I played Blackjack again. Again I won $150. This time I sat alone at a table with an Asian lady dealing the cards. 6 deck non-automatic shoe. I was totally uncomfortable playing with her. She dealt the cards so quickly. I wasn't used to it. She was practically playing my cards! I quickly walked away. But not after winning $150 again (this time in 10-15 minutes). Ray and I got drinks and spent some time outdoors. We then went back in and I decided to play some more. This time I sat at a table with 6 other players. I chose to sit on the left side of first base. Games were much slower. Slower enough so that I could think and play. I wasn't studied up on the card counting and so I just played as I usually do. It was sad in fact. I lost all the money that I won earlier and almost lost 2/3rd of the money I brought to the casino ($300 of the money that I received from selling those Aerosmith tickets). I won back a third of it (just barely coming back from the brink). And I walked away with $200 of my original $300.

To summarize, after coming home from the Thanksgiving outing I decided to study again. I downloaded an app for my iPhone playing Blackjack regularly (last week). What I learned was the more I learned about the odds for winning and losing and what I was paying for them I realized that I wasn't so sure that I enjoyed playing anymore. What I found from the app for the iPhone was that I didn't like the risks that I needed to perform to win. Knowing about the card counting techniques I thought it would be just as easy as playing on the cheap (minimum bets) on the average deck and playing higher amounts on the hotter decks. But what I found was that the theory just didn't work with the simulation program I bought. I was pissed. I played nearly 2000 hands before I found a system that seems to work (I read it in another book that I found). The way that I was beating the simulation (not exactly all the time) was by playing a progression when I won. When I win, double your money. Win, and slowly decrease the amount waged to "lockin" some of your winnings. When I lost, and when I lost consecutively, hopefully it was for the miminum wager. However, there are some occasions when the run of cards gets away from you. You just get bad cards. Hopefully your not chasing the progression just to get even! And unfortunately that's exactly what happens. When you have lost 5-6 hands in a row your ready to place bets 10 times the original mimimum amount. That's a huge risk. And it's not outside the possibility of losing 10 in a row (I lost 10 in a row and the last 3 of those bets were for $500 -- good thing it was just an iPhone app!).

What I learned was that I didn't like putting so much at risk to be successful at Blackjack. And success in Blackjack does have it's costs. Time for instance, and a higher than acceptable propensity for risk. Both of which I don't have a healthy supply of.

Thursday, July 29, 2010

New York 2

We left for America after the World Cup game between Germany and Spain. It was a really tight game. Not many chances. We left around 4:50 PM and I drove. Encountered a major rain storm around Hamilton area. We got to the Duty Free shop around 6:30 PM. Picked up some munchies, beer and drinks and we crossed the border.

I get nervous at the border. You have to try and relax. Americo was driving at this point and he was nervous at the border. It was kind of funny. Where you going? Long Island. Where in Long Island? Umm. What was it called? Rockville. Why are you going there? To play hockey. Blah blah blah.

We entered America around 7 PM crossing the Lewiston Bridge. We took the New York route on the I-90 to Syracuse and then took the I-81 south. We stopped at Homer, NY to get some gas and food. But Homer was such a small town. The sign off the highway said there was a food stop and gas stop but Homer had nothing (practically). We filled up on gas ($2.59 per gallan, $25) and kept going. We learned that we made the wrong stop and that where we should have stopped at was Cortland. It was funny because Cortland had all the amenities that you would expect from a rest/gas/food stop. Homer and Cortland couldn't be more than 2 miles apart. But Cortland had the new facilities and Homer had the old mom and pop gas station (and that was it!).

We stopped at Tim Horton's and had dinner. It was 10:10 PM. We finally hit the road around 10:35 PM and we didn't stop until we got to New Jersey. Americo drove the whole way. I fell asleep around 11:30 PM and was in and out of sleep until 12:30 PM. We arrived at the Ramada Inn in Rochelle Park, NJ around 1:50 AM. We checked in and expected to receive the cheap walk-in special that we saw advertised through roomsaver.com. They wanted to charge us $85 for the night. Lucky Americo brought it up and we paid the $59 that we expected. It was late. It was a good idea to fight the fee. But after a long drive I can see how easy it would be to just pay it.

We were in our hotel room around 2 AM. I went to bed around 3 AM. Taking some time to get a feel for the room and watching some TV until I fell asleep. I woke around 8:30 AM and got us some breakfast (before the food was gone). We then talked to the desk to see if we could get another night at the hotel. They wouldn't give it to us at the rate that we wanted. So we decided to leave. We figure we could find another hotel at the cheaper rate in Jersey. We looked around on roomsaver.com and decided on the Hampton Inn in Elizabeth (my initial destination choice). I drove to Elizabeth and when we entered we were pleasantly surprised. The Hampton Inn was quite comfortable. Much better than the Ramada. Little things make a big difference in the look & feel of a place. The Ramada had dark carpets but the hallway wasn't cooled by an A/C. The Hampton in the front foyer had dark wood floors. The walls were a cool cream striped satin looking wall paper. The seats in the dining area (small but cozy) were comfortable, inviting modern styled chairs. Whereas the Ramada was red and dark when we walked in that late night. In the morning it was brighter but because of the layout of the hotel there wasn't as much natural light. So it felt cramped and dark.
The rooms felt different as well. The Hampton had light coloured blankets while the Ramada had pastel, dark coloured blankets. The Hampton just felt fresher. The Ramada's blankets was just rougher on the skin. I just think it's interesting the differences a few select features makes on the complexion of a place. Both hotels had a dark wood finish. But because of the light in the Hampton you could see the finish. It felt more luxurious, more refined, cleaner and tidier. Just a better hotel. It did cost $20 more but it was worth it.

We signed in around 11:30 AM. We hoped to be out of there by 12 PM but that was just a hope. We left around 12:30 PM looking for the Elizabeth train station. We asked the guy at the desk but he directed us to the shuttle bus that goes to the Newark Airport where we could take the NJ train to NY Penn Station. We later learned that the Elizabeth train station is not out of commission. The hotel shuttle hotel guests to and from the airport. The NJ train was far more expensive because the transport is used to pay for the airport. Therefore, we paid $15 (Americo paid $11.50) to take 3 stops to NY Penn station. The $15 was much different than the rate that was quoted from the NJ transit website. I got a quote of $6.50 from Elizabeth (which is one stop further than the Newark Airport) compared to $15. I was pissed off about this.

We got to NY Penn station around 2 PM. Picked up a day-pass for the NY subway system and our first stop was the WTC site. We took the E line to the WTC. Took some pictures. I was amazed that they could fit 2 buildings in the space that I saw. Amazing! And with the congestion of the location it's surprising and scary that 2 large buildings would fall in such a dense urban area.

We started to walk to Battery Park (where the statue ferries disembark) but the direction that an officer provided us appeared to be different than what I expected. I checked out the map and realized that there is a Battery Park City (West of WTC) and a Battery Park? I'm doing a search again now and I guess I was wrong (again!). Anyway, we took the subway back to Penn station (we missed our exit at Chambers) had lunch (at Moe's Burrito Grill) and then we headed south again (along the 1 line) towards the South ferry stop. We exited and found the Staten Island ferries (not the statue ferries) and decided to take the trip. We played it loose in the city and it was great. 20 minute ride to Staten island and back again we had a good time. Americo got a chance to relax. I had the chance to take pictures of Lower Manhattan and the Statue of Liberty.

It was around 5 PM at this point. We then took the R train to Wall street and we walked around a little. Took pictures and then started up (7 line) towards the Empire state building. We decided to wait till later for the Empire state building so we took 7 line again to Times square. Americo stopped at an electronic camera shop and 10 minutes later Americo had bought a 70-300 mm zoom lens for his Nikon D3000 digital SLR. It was maybe 7:30 PM at this point. Our last stop was the Empire state building. Fantastic monument to go visit. Beautiful, regal and iconic. It's incredible that the building should now symbolize the city of New York. I fell in love with the building. It's funny because my first impression of the building was one of surprise. The building has held up pretty well over the years. I was surprised that it didn't look older. The facade was very much clean and crisp (almost fake looking). Did they have renovation done to clean it up? It looked too clean to me. The front entranceway has got the signature 350 on it. There is a doorman and the entranceway. A rotating entranceway into the building. A long corridor leading to a desk. A beautiful mural behind the desk and dressed in gold. The image is of the building surrounded by golden beams of light. The imagery is fantastic. I really enjoyed the feeling of the place. It just brings back the images of big money New York. I can imagine Clark Gable singing 'Puttin' on the Ritz'.