A few months ago I ripped through a number of MVVM JS frameworks while starting a new project and found Knockout.js to be exactly what I was looking for. I found their introductory tutorials to be an excellent place to start but also a bit of a poor reference since they have to be completed step by step. Below are my notes on the 5 knockout tutorials for eas(ier) reference.

 

Tutorial 1 – Introduction to Knockout/MVVM

View

View Model

2 -Lists and Collections

View

View Model

3- Single Page Applications

View

View Model

See also: http://jsfiddle.net/rniemeyer/PctJz/

4- Custom Bindings

View

View Model

See also: http://www.knockmeout.net/2011/07/another-look-at-custom-bindings-for.html

5 – Loading and saving Data

View

View Model

Chrome comes fully loaded with some powerful dev tools, one of the most useful is probably the V8 JS debugger:

I REALLY wish that things could be a little different when debugging complex JS:

 

I keep getting emails from eBay about “Visionary Picks” and other junk I don’t care about. Usually unsubscribing from this type of stuff is fairly trivial but it seems eBay is almost as sneaky as LinkedIn when it comes to unsubscribing:

Well Gmail to the rescue! Apparently this feature was implemented in 2009 but I haven’t really noticed it till recently. It doesn’t work on all emails, but I’m pretty impressed that it can unsubscribe me without having to log into eBay. The last thing I need right now is more ALIEN merch.

Gmail to the rescue!

Note: This is an expansion on a comment I made on a  Reddit thread a few weeks ago. People like it so I hope you find it useful aswell.

Subnote: This is a post about PHP/JS/CSS/HTML.

Currently I’m lead dev working on a codebase for a website that’s about 12 years old. It has a few thousand source files and sparse documentation. Legacy code is awesome! Not every project is the same but here’s the type of stuff you might find:

  • You have no clue what the dependencies are or how things interact
  • Naming conventions aren’t the same across the board
  • Error handling is same as above
  • You have “current” best practices or just strange things going on (tables, in-line styling, <br><br><br> – basically the lack of a front-end dude since the idea of that 10 years ago wasn’t that huge)
  • Commments of all sorts: cryptic messages, old code, lines left over from debugging

Some people might cringe but it’s actually quite fun! Anyone can write code and many people can design intelligent software; it takes a true hacker to be able to sort through a complex legacy system and work within it. It is a big challenge but the reward of this kind of undertaking is immense.

Best Practices

  • Develop a style guide for code and follow it for any new additions. Update older code stylistically as you work on it. Don’t worry about how much of your time gets devoted to pressing [tab] and [enter] – or reindent if you have that option.
  • Develop a general code-structure if you possible based on what the common consensus is so far (even if it’s not perfect). Try to enforce it wherever you can. I make templates for each type of file to speed things up in the future.
  • Comment everything as you come across it. Now by that I mean comment functions and files ONLY. I like the JavaDoc style personally, each file has description/@author/@version/@package and each function has description/@param/@return. Remove in-line comments where possible. This is how all of my files start:

    I’m not going to get much deeper into commenting because that’s a whole post on it’s own, basically just keep it clean and simple and don’t write more than you have to.
  • Create logic diagrams for overly complicated processes. I spent a day tracing how an order is processed from being an item in the session to going through the billing system and getting created via various APIs, turns out the process was MUCH more complicated than I had originally anticipated but having a visual map of it makes it both easier to work with and easier for others to understand.
  • DONT REWRITE ANYTHING UNLESS YOU HAVE A THOROUGH KNOWLEDGE OF IT’S INTERACTION WITH THE ENTIRE SYSTEM.
  • Working with inline styles can be a bit of a pain. It’s always challenging because the elements you’re styling can be split up among a number of different files and presented in a number of different contexts. I completely revamped the CSS on one websites by using StyleDocco (Kalei is also a decent option). The tool itself isn’t that powerful, but forcing yourself to go through the code and find how elements are being coded and styled is invaluable. Once you have everything laid out you can get a good idea of what your class requirements are and start grouping like items together. As a bonus you also create HTML standards from the usage examples you find. This type of documentation is also a great way to make notes about how various items could be improved in your next major revision. (Note: the ability to let you search the entire project source and display how code is being used is crucial – CLI or preferably your IDE).
  • Ultimately always think of the future, you may not be there for more than six months so leave things in a way that your team or your eventual replacement will have an easier time. Don’t be lazy and don’t let the laziness of others rub off on you.

Now I don’t consider myself an expert by any means. I’ve been in the industry for 8 years and every project/environment/team is different. This is just how I like to do things. Also if you haven’t read it, this book may change your life (and probably gave me alot of inspiration for this post).

Keep things sane, semantic and fun :)

Omegle is a weird place. Mostly I think it’s a hangout for perverts (during 4-6am anyway). Thinking about it, I guess the signal/noise ratio is about on par for anything else you’d find on the net. Lately a combination of insomnia and boredom have led to many hours wasted on this website. This is a post about missed connections and talking with strangers.

Abstraction, specifically in terms of human-computer interaction, is a very intriguing topic. I’m not going to rant about how awesome it is to have access to the limitless amounts of UX data we have today. I will talk about one metric though, ASL. I don’t know about other chat systems but on Omegle the standard “A/S/L” greeting has devolved to just “S”. Most of the conversations I get into go like this:

Stranger: M

Stranger: You?

Usually these are followed by a prompt disconnect shortly after my gender is disclosed. I’m curious to see where we’ll be in 10 years.

Anyway last night I met Sierra, apparently she’s 24 and she used to live in Toronto but now she lives in NYC. If you’re from Omegle let me phrase that in a way you can understand:

24/f/nyc

I didn’t learn that much about her, she mostly asked me questions about my life and how I waste most of my time. She told me that saying I’m a lanky pale gingerkid isn’t the best way to pick up ladies. No shit :P Anyway the connection we made was quite awesome, all I remember was that she volunteered alot and was in some medical related field (physio….?). Mostly I liked the fact she was a real human and not an ASL robot like the previous 10 matches. We talked about exchanging pictures but decided it wasn’t really relevant, we did exchange contact info though. Well, we tried.

She gave me her KIK username shortly before I managed to finally fall asleep. I probably should have wrote it down or put it into my phone; I figured leaving the chat open in my browser would be safe enough. Well it turned out that even though my Macbook, which was connected to the charger, which was connected to the powerbar, which (believe it or not) was connected to the power outlet, wasn’t actually connected to any power at all. That little orange powerswitch? Yep, that was flicked off.

I’ll probably never talk to Sierra again so here’s an open letter:

Dear 24/f/nyc,

Whether that’s your real age, sex, and location I do not know or care. You’re pretty cool but you need to work on your sleep patterns. Enjoy your life and if you ever move back to Toronto I hope you’re on Reddit.

@psobko

Footnote: As I was writing this I opened up a new Omegle chat to get a screenshot of the interface. At first the person seemed AFK so I was quite relieved to avoid the guilt of starting a conversation I didn’t really want to have. They ended up typing and we had a very meta conversation about these types of missed connections. Ironically enough I tried to do a Command key icon-c to copy something from the window, as fate would have it my finger hit the “W”. Life is funny.

Re-indent is an absolute necessity in any text editor; why this isn’t shortcutted by default in Sublime2 is beyond me. To make your coding experience much more enjoyable I’d set this shortcut right off the bat, maybe even before installing Package Control (shocking I know).

A quick rundown on how to set this up:

Preferences > Key Bindings – User

And then after making sure you’re not overriding something important, set up the shortcut:

Apple Protip: Command key icon key == “super”

Incase you don’t know what re-indent does, it turns:

into:

Clean clode, clean mind.

So maybe this already exists, maybe it doesn’t. Unless I’m missing something big, it’s not a default option in most of the IDEs/editors I use. By default when selecting a string, whether it’s a variable/class/whatever you’ll have a segment of the string selected only if it’s been segmented by dashes. This means that double-clicking on a piece of a string such as say:

Will select this:

Which is awesome if you’re using a language/coding style that uses these kinds of strings as names. Things start to suck when you’re using underscores though, as far as I know it’s only possible to select the entire string. This is a bit of a waste of time since now instead of selecting a much needed segment you’ll get something like this:

What I want is selective selection: have the entire string selected by default or if a certain key is pressed then just select a segment. This would mean double clicking on like so:

This doesn’t apply to just underscores either, I’d want to see this feature for camelCase as well:

And in case your’re wondering why this is would be useful:

  • quickly renaming incorrect typeahead completions (NSMutableString ->NString)
  • qickly remaming strings (span4 -> span8)
  • quickly replacing multiple segments when doing things like copying methods
  • quickly copying segments that need to be used elsewhere  (setActiveSession -> activeSession)
  • … and many more scenarios that don’t immediately come to mind.

I’d want to test drive something like this in Sublime2 if I gave plugin development a second chance (Urg Python). If there’s anything like this out already then by all means please let me know.

edit: so many typos!

I feel like I’ve neglected this place a little lately so…. Redesign :)

Happy New Year!

Edit: Damn I didn’t get a before.

So the iPhone 5 is out and iOS 6.0 gives us some really handy tools for supporting both the older 3″ screens and the new 4″ screen through something called Autolayout. With iOS 6.0 at only about 60% adoption (pretty amazing considering it’s only been about a month) that leaves alot of older devices which don’t support this new option. Here’s my workaround to support the iPhone 5 on iOS 5.1.

First off select the older SDK in your build targets.

Then make sure to disable autolayout. You can do this by selecting the storyboard and disabling the option in the file inspector:

The last step is to add a new iPhone 5 launch image. You can save this blank image as a base or create a new one. It should be 640 × 1136 pixels and named Default-568h@2x.png

With these 3 things taken care of your iOS 5.1 app will now be able to run full screen on the iPhone 5. Obviously you may need to go inside and tweak how things are positioned depending on how your views are setup.