?

Log in

johnromkey [entries|archive|friends|userinfo]
johnromkey

[ website | My Website ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

CODE: Notes on Ember and Ember App Kit [Mar. 22nd, 2014|04:28 pm]
johnromkey
[Tags|, , ]

[Originally published at romkey.com. Please leave any comments there. You can login there via OpenID using your Livejournal account.]

I’ve recently been working with EmberJS, a Javascript framework for building MVC-based web applications. I’m liking it a lot. It feels well thought out, well designed, and isn’t afraid to make decisions for you.

The environment I’m using it in also uses Ember App Kit, which will get you off the ground much faster than writing an Ember app by hand from the ground up. Ember and Ember App Kit like to use Handlebars for their templating system. Handlebars also seems well thought out, well designed and easy to use.

Here are a few notes on gotchas and useful things I’ve run across so far.

I’m looking forward to trying out Ember inside a Chrome packaged app. Packaged apps generally have trouble with Javascript templates – most template software uses eval, which is forbidden in the main code in an app (but allowed in a special sandboxed page that has very restricted access to Chrome Javascript APIs). It looks like the Ember App Kit should solve this problem by precompiling the templates…we shall see.

Helper Names

Ember wants all Handlebars helper names to have a dash in them. If your helper doesn’t have a dash in it, you’ll have to register it by hand – check these instructions for more information.

Registering Helpers

While Ember seems to suggest using Ember.Handlebars.helper or Ember.Handlebars.registerBoundHelper to register helpers, using either of those in the helper file itself under Ember App Kit blows up. I ended up using the makeBoundHelper method instead, for instance:

export default Ember.Handlebars.makeBoundHelper(function(word) {
    return word.toUpperCase();
});

Source Maps

transpiled sourcemap CODE: Notes on Ember and Ember App Kit

If you want to debug your code, be sure to use a web browser which understands source maps correctly. Otherwise you’re going to be inspecting and stepping through a massive pile of transpiled code that will make no sense to you. Use Google Chrome. To be fair, I found that Chrome didn’t get me to the right place, or exactly the right line, 100% of the time, but it was very close and way easier to deal with than that one time I tried to debug Ember code in Firefox without source maps enabled. Use a recent version of Chrome, Safari 7.0 or later, or a recent Firefox with “Show original sources” turned on.

To set a breakpoint, look in the debugger for your source files under /assets/tmp/transpiled/app – not quite where you’d expect to find them.

Observing a Computed Property

Ember allows objects to have “computed properties” – that is, when you reference a property with get or set, a function will be called. Ember also allows you to “observe” properties and have things automatically trigger when the properties change (this allows pieces of web pages to automatically update as the web application’s state changes).

There’s a bit of special magic you need to do if you want to observe a computed property. The property’s value is never set unless you call get at some point. In order to start things off you’ll need to have an init method in the controller with the property and call get on it there.

var MyController = Ember.ObjectController.extend({
    init: function() {
    this.get(‘myComputedProperty’);
});

This Stack Overflow article goes into detail.

Ember Inspector Chrome Extension

If you’re using Chrome, you will almost certainly want the Ember Inspector extension. This extension inspects Ember’s internal state and allows you to

LiveReload Chrome Extension

If you’re using Chrome, you  will almost certainly want the LiveReload extension. This extension integrates with ‘grunt server’ to automatically refresh the page when you update your Ember application. My experience is that it’s enormously convenient.

Helpers Not Observing Properties

I’ve had some problems with a helper not firing when a property it observes changed. For instance,

export default Ember.Handlebars.makeBoundHelper(function() {
    return theWord.toUpperCase();
}, ‘theWord’);

isn’t updating for me when the property theWord changes. I am confident this has something to do with my application and isn’t due to a bug in Ember. It’s the only issue I haven’t tracked down so far.

link

CODE: Notes on Ember and Ember App Kit [Mar. 22nd, 2014|04:28 pm]
johnromkey
[Tags|, , ]

[Originally published at romkey.com. Please leave any comments there. You can login there via OpenID using your Livejournal account.]

I’ve recently been working with EmberJS, a Javascript framework for building MVC-based web applications. I’m liking it a lot. It feels well thought out, well designed, and isn’t afraid to make decisions for you.

The environment I’m using it in also uses Ember App Kit, which will get you off the ground much faster than writing an Ember app by hand from the ground up. Ember and Ember App Kit like to use Handlebars for their templating system. Handlebars also seems well thought out, well designed and easy to use.

Here are a few notes on gotchas and useful things I’ve run across so far.

I’m looking forward to trying out Ember inside a Chrome packaged app. Packaged apps generally have trouble with Javascript templates – most template software uses eval, which is forbidden in the main code in an app (but allowed in a special sandboxed page that has very restricted access to Chrome Javascript APIs). It looks like the Ember App Kit should solve this problem by precompiling the templates…we shall see.

Helper Names

Ember wants all Handlebars helper names to have a dash in them. If your helper doesn’t have a dash in it, you’ll have to register it by hand – check these instructions for more information.

Registering Helpers

While Ember seems to suggest using Ember.Handlebars.helper or Ember.Handlebars.registerBoundHelper to register helpers, using either of those in the helper file itself under Ember App Kit blows up. I ended up using the makeBoundHelper method instead, for instance:


export default Ember.Handlebars.makeBoundHelper(function(word) {
    return word.toUpperCase();
});

Source Maps

transpiled sourcemap CODE: Notes on Ember and Ember App Kit

If you want to debug your code, be sure to use a web browser which understands source maps correctly. Otherwise you’re going to be inspecting and stepping through a massive pile of transpiled code that will make no sense to you. Use Google Chrome. To be fair, I found that Chrome didn’t get me to the right place, or exactly the right line, 100% of the time, but it was very close and way easier to deal with than that one time I tried to debug Ember code in Firefox without source maps enabled. Use a recent version of Chrome, Safari 7.0 or later, or a recent Firefox with “Show original sources” turned on.

To set a breakpoint, look in the debugger for your source files under /assets/tmp/transpiled/app – not quite where you’d expect to find them.

Observing a Computed Property

Ember allows objects to have “computed properties” – that is, when you reference a property with get or set, a function will be called. Ember also allows you to “observe” properties and have things automatically trigger when the properties change (this allows pieces of web pages to automatically update as the web application’s state changes).

There’s a bit of special magic you need to do if you want to observe a computed property. The property’s value is never set unless you call get at some point. In order to start things off you’ll need to have an init method in the controller with the property and call get on it there.


var MyController = Ember.ObjectController.extend({
init: function() {
this.get(‘myComputedProperty’);
});

This Stack Overflow article goes into detail.

Ember Inspector Chrome Extension

If you’re using Chrome, you will almost certainly want the Ember Inspector extension. This extension inspects Ember’s internal state and allows you to

LiveReload Chrome Extension

If you’re using Chrome, you  will almost certainly want the LiveReload extension. This extension integrates with ‘grunt server’ to automatically refresh the page when you update your Ember application. My experience is that it’s enormously convenient.

Helpers Not Observing Properties

I’ve had some problems with a helper not firing when a property it observes changed. For instance,


export default Ember.Handlebars.makeBoundHelper(function() {
return theWord.toUpperCase();
}, ‘theWord’);

isn’t updating for me when the property theWord changes. I am confident this has something to do with my application and isn’t due to a bug in Ember. It’s the only issue I haven’t tracked down so far.

link

BBC’s Best Typo [Feb. 24th, 2014|02:32 pm]
johnromkey
[Tags|]

[Originally published at romkey.com. Please leave any comments there. You can login there via OpenID using your Livejournal account.]

With all the flap last week about Facebook buying WhatsApp for a stupidly large amount of money, I think most people missed BBC’s awesome typo on their first attempt at breaking the news. Here’s a screenshot of the notifications for it and its correction (and I swear, this is unmodified except for the hilight I added):

IMG 4821 BBCs Best Typo

link

On My 50th Birthday [Feb. 13th, 2014|11:13 pm]
johnromkey
[Tags|]

[Originally published at romkey.com. Please leave any comments there. You can login there via OpenID using your Livejournal account.]

So I’ve finished half a century on the Earth. The word century always sounds impressive. And while fifty years sounds impressive, half a century sounds even better. I don’t feel fifty years old but I really don’t feel half a century old.

So many things have turned out differently from what I ever might have imagined.

Growing up as I realized I was attracted to men, I never imagined that I would some day be 15 years into a relationship with a great guy. Marriage wasn’t even a possibility, so being five years married to him was unimaginable. Instead I could only imagine that I would spend my life alone.

I would never have imagined that I would become as fat as I did. And once I did, I never imagined that I’d go through a process that would help me get my life back under control. I never would have imagined I’d be so interested in helping other people get their lives back as well. Or that I would put so much time and energy into helping a company like Precision Nutrition, a truly modern company more interested in collaborating with its clients than lecturing them.

Even a few years ago I wouldn’t have believed that today I would be someone who would be happy to eat an egg white omelet for his birthday breakfast (not that it would be merely acceptable but that it would be my preferred choice), or someone who would set a personal record for the hex bar deadlift on his fiftieth birthday. I wouldn’t even have known what a hex bar deadlift was. Today I can do a hex bar deadlift of 305 pounds… 10 pounds more than the record set by a middleschooler at my gym… I have a ways to go before I can out-lift guys my own age. But, last week I couldn’t lift that much.

I won’t even start on how much technology has evolved and how different the computer industry is today from even a decade ago.

If there’s one wish I could have come true: I wish people would own their own shit.

Whether your shit is hating on certain people because they’re different from you, eating everything in sight because you’re anxious or scared or lonely, compulsively helping people, telling people what to do, telling people not to tell people what to do, ranting and railing against the world on Facebook, drinking yourself to sleep at night… whatever it is, I wish you would own it. Accept it as truly yours. Not something your parents made you do, not something society made you do, not something some old guy with a white collar made you do, not something some book told you to do or believe.

No, figure your shit out and truly own it. Take responsibility for it. Figure out how it affects you, figure out how you affect the world. Put yourself on the other side of your own shit. Own and figure it out.

Because ultimately, if you don’t own your own shit, it’s going to own you.

link

Strong Unique Passwords and Why I Don’t Use Public Computers [Jan. 21st, 2014|12:31 pm]
johnromkey
[Tags|, , ]

[Originally published at romkey.com. Please leave any comments there. You can login there via OpenID using your Livejournal account.]

Recently I reported some phishing scam spam coming from a friend’s account – it looked likely that his email account had gotten cracked.

No shame on him for that; it happens all the time.

These are a few things that I do to help avoid that myself.

[small update: I know this list may be intimidating - just doing a few things on it can help a lot - don't worry about trying to be perfect - you can't be. But if you try doing one or two things that you don't already do, you'll definitely improve the security of your Internet accounts]

1. I only login from my own computers

I only use public computers for simple web viewing. I never log in to any services, particularly email or financial, over a public computer. Using a public computer is just too dangerous. It’s far too easy for it to be harboring a key logger or other malware which could capture my login.

Also, I carry an iPhone and often an iPad. If I need to do something that requires me to login, I use those.

2. I only follow links I’m confident of

First of all, I don’t follow links in email from strangers. Some web browsers have bugs that allow simply loading a web page to run malicious software on your computer.

Second, when I receive email from someone I know I look for whether it sounds off – is it out of character? Does it not sound like it’s written by the person who sent it (out of character, typos, spelling errors?)

Third – I always check a link before clicking it. Even my Macintosh is not 100% impervious to malicious web sites (Java has had some very high profile vulnerabilities). And if I click it and it’s acting weirdly (the email said Google Docs, why is it asking me for a Yahoo login??) I back off. For instance, this is not a link I would follow to get to Google: http://googlemebaby.foobar.com/

There’s almost always time to send a note back to the person who supposedly sent you suspicious email and ask if it’s correct. And given that most phishing scam email is sent by software rather than a human, odds are good there won’t be someone there to write you back with a lie.

3. I use strong, unique passwords on web sites

Strong passwords are unique strings not based on personal information or words in the dictionary. For instance, m;8maUt7CfQD is an example of a strong password. Does it mean anything to you? Sure doesn’t to me.

By using a strong password I make it much more difficult for software to crack my account by trying words from a dictionary or well known passwords. Software can easily try hundreds or thousands of passwords a second, so if I use an easy to guess password, my account is unlikely to stand up to an attack.

By using a unique password for each web site or service if the web site or service is cracked and its user information stolen that won’t affect any of my other accounts.

A side effect of this is that I don’t know my own passwords!

4. I use a password manager

Since I don’t know my own passwords, how do I keep track of them?

First of all, I’m on a Mac and I let my web browser memorize them for me (this will make security geeks blanch but it’s a compromise that helps make having strong passwords survivable). MacOS X 10.9 Mavericks also has built-in support for creating stronger passwords in Safari, and can automatically sync stored login information to my iPad and iPhone (again, this will likely make security geeks crazy as you’re just trusting Apple to do the right thing in protecting this information).

Second, I use 1Password, a password manager which integrates with all major web browsers and also works on most smart phones and tablets.

1Password records login information for web sites and can automatically fill it for you when you need to login. It can also suggest strong passwords and has a handy option to make the passwords pronounceable, which means you have at least the ghost of a chance of being able to remember some of them.

1PasswordIcon Strong Unique Passwords and Why I Dont Use Public Computers

1Password on the Mac App Store

1Password for iPhone, iPad and iPod Touch

1Password for Android

1Password for Kindle Fire

1Password for Windows

Of course, if someone gets your password manager’s list of passwords, you’re screwed. The password manager encrypts its list of password, but you choose the key (a master password for your passwords), so if that key is weak and someone gets the file, game over.

5. I only give my id and password to the site it goes with

There are many add-on services for web sites which need your login information in order to access the site and provide the service they offer.

For instance, I use a package tracker which offers to login to my Amazon account and automatically track packages that Amazon is sending me – but, without casting aspersions on the makers of this package tracker, there is absolutely no way I am giving my Amazon login information to strangers.

6. I lie when answering to personal questions during account signup

Ever sign up for a random photo service that wants to know your mother’s maiden name and where you were born – you know, those questions your credit card company or bank like to use to make sure you’re you?

Yeah, I don’t think some random company needs to have that information. I wouldn’t give them my social security number, either. So I make something up – I have a couple of stock answers for this kind of thing. Generally I find this a poorly designed security process which unfortunately I have to deal with if I want to use the service. So I tell them a lie that I’ll be able to remember (or I record the answer somewhere).

7. I only install software from known sources

I’m happy to install software from sources I already trust, and I’m willing to extend trust – usually to well known businesses or individuals or businesses I’ve seen recommended. I don’t install goofy extensions that change my browser’s behavior or give me cutesy cursors (“comet cursor” was an infamous bit of Windows malware that many, many people installed).

8. I use protection

I’ve installed the Chrome Shield extension which monitors the Chrome browser and warns me if I install a malicious extension.

If I were running Windows I would absolutely run some kind of antivirus software on it. I’m generally working on a Mac, which is not impervious to attack but much less likely to have problems, especially given that I don’t indulge in risky behavior.

If also never connect my computer directly to the Internet (for instance, directly to a cable modem or DSL modem). I always connect it through a “firewall” device. A firewall will prevent most unintended direct access of computers it protects. Most wifi access points and routers act as a firewall, although firewall functionality may need to be enabled.

Extra credit: Use a unique email address with each site

When a cracker manages to break into your account on a web site (or get the user list for a web site), they’ll have your email address. One way to enhance your personal security is to use a unique email address for every web site you have an account at – when you do that and have a strong password, you’ll definitely reduce the likelihood that a cracker will be able to break into your accounts on other web sites.

I realize this is a huge pain. If you use Gmail, you may not realize a simple thing you can do to make this work for you. If you put a plus sign in your gmail address, gmail will ignore the plus and everything after it when it matches addresses. So, for instance, you could sign up for Amazon with “myname+amazon@example.com” and any mail to that address would be received by “myname@example.com”. A human would likely guess your correct email address but most attacks are automated, so this may help save your other accounts from attack.

Extra credit: Use two-factor authentication

Two-factor authentication requires you to give more than just your password when you login. For instance, when you login you might be required to enter a code delivered by a text message in addition to your password, or you might enter a code displayed by a app on your phone in addition to your password. This makes it much more difficult for someone to break into your account, but it also makes accessing your account less convenient for you.

 

 

 

link

iPad Air First Impressions [Nov. 2nd, 2013|09:43 pm]
johnromkey
[Tags|]

[Originally published at romkey.com. Please leave any comments there. You can login there via OpenID using your Livejournal account.]

IIMG 4363 iPad Air First Impressions headed over to Best Buy first thing Friday morning… they opened at 8AM and handled the iPad Air rollout very nicely. It was raining hard… they gave reservations for particular units to people who were there early and didn’t make anyone stand in the rain. (They also handled the iPhone 5 very nicely, even making appointments for people to come in to activate their new phones – not as streamlined as pickup at Apple but still pretty civilized).

I don’t think there were more than 10 people there at 8AM. I was in and out within a few minutes. I went home, backed up my old iPad to iTunes, connected the new iPad and restored. The whole process was very painless (hint: to help keep it painless, choose the option to encrypt your backup – otherwise iTunes will intentionally not store passwords and authentication information in the backup).

[updated: You can also backup and restore through iCloud - I chose to use iTunes because doing a local backup and restore over USB is much faster than doing a backup and restore over the Internet. I normally have my iPad and iPhone set up to backup to iCloud and I recommend you do that as well]

The new iPad is slimmer and lighter than the previous generation. The screen is the same size. It was about 1/3 less. The difference in feel is remarkable. It’s quite comfortable in my hand. The difference in comfort is surprising.

The fingerprint scanner on the iPhone 5S seems to be limiting the production rate of the new phone, so I would have been shocked if it made its way into the new iPad this year (although I expect it next year, and expect to see it on Apple’s computers eventually, too). Still, I’ve gotten enough used to it on the phone that I would love to have it on the iPad.

I’m also very impressed that Apple managed to shrink the size and still get a very large performance bump. I would expect next year’s update to be much more modest.

If you use an iPad regularly, it’s well worth checking out the new model.

Funny thing – of course Apple is matching the iPhone 5S colors on the iPad Air (except for gold)  - so black is no longer black; it’s “Space Gray”. Except in the box. Which still says “black”.

IMG 4360 iPad Air First Impressions

link

CODE: jQuery’s :contains and White Space [Aug. 12th, 2013|01:15 pm]
johnromkey
[Tags|, , ]

[Originally published at "romkey". Please leave any comments there. You can login there via OpenID using your Livejournal account.]

Over the weekend I ran into one of those situations where it felt like I had found a bug in a very commonly used portion of a very commonly used piece of software (jQuery). Of course, 99.99% of the time when that happens, I’m wrong, not the software.

I recently started writing some Javascript and CSS to completely change the appearance of a web site I frequently use and make it look more modern and less cluttered. In the course of doing that I had call to use jQuery’s :contains selector. :contains allows you to select DOM elements which contain text. For instance, you would use a query like:

$('legend:contains("Options")')

to select this HTML:

<legend>Options</legend>

In an effort to make my code more readable, I’ve been trying to be careful and consistent about my use of whitespace – lots of it to help make code more readable. I started doing this in Perl but have carried it over to Javascript.  So instead of the Javascript I quoted above, I wrote it as:

$( 'legend:contains( "Options" ) ')

Note particularly the spaces around “Options”. If this were an ordinary Javascript function call those spaces would be fine. Instead, this is being parsed by jQuery’s Sizzle engine, where apparently the white space is not okay. This leads to the really unexpected outcome of :contains failing all over the place.

To be fair, jQuery and Sizzle never promised that white space would be okay here. I can’t claim this is a bug, just unexpected behavior.

Try it out with a jsfiddle.

link

Priorities [Jun. 30th, 2013|12:38 pm]
johnromkey
[Tags|]

[Originally published at "romkey". Please leave any comments there. You can login there via OpenID using your Livejournal account.]

Interesting how Amazon prioritizes use experience. Of course they want to make it easy to shop, right?

I can buy something via 1-click without having to re-authenticate myself. In fact I can buy a whole lot of stuff. I’m logged into Amazon but I haven’t re-authenticated myself in quite a while… no problem. Click, buy, click, buy, click buy.

Want to cancel an item in that 1-click order? Better check my password! Because I’m sure accidental cancellations happen much more often and are much more serious than accidental orders!

link

Pill Pockets [Mar. 21st, 2013|07:01 am]
johnromkey
[Tags|]

[Originally published at "romkey". Please leave any comments there. You can login there via OpenID using your Livejournal account.]

IMG 3332 Pill Pockets Now that our cats are becoming elderly, they need some kitty meds. Nothing too serious, but some daily pills, probably more to come.

We’re very fortunate to have cats who love pill pockets and are not clever enough to extract the pill from the pocket and just enjoy the treat. They love them enough that they demand them on schedule.   IMG 3333 Pill Pockets

 

The pockets themselves are very easy to deal with… bits of pliable meaty stuff shot full of preservatives so that they don’t decay sitting in a bag on the counter. Press a pill into them and you’re ready to trick your pet into eating their meds.

 

 

 We can get pill pockets at our local coop but I found they’re a lot cheaper on Amazon when bought by the case. An individual package of them on Amazon costs about the same as it does at our coop, but a case of six is substantially cheaper.

As of the time I’m writing this, a case of 6 costs about $25. Buying them separately via Amazon or my local store, 6 would cost $36. So the case is a $11 or roughly 30% discount.

If you’re really cost sensitive on this sort of thing I suspect that most people would find a pill wrapped up in a little raw ground meat would work just as well.

(disclosure: the above is an affiliate link that gets me a kickback from Amazon)

 

link

Down One Cat [Mar. 18th, 2013|08:10 pm]
johnromkey
[Tags|]

[Originally published at "romkey". Please leave any comments there. You can login there via OpenID using your Livejournal account.]

Temporarily.

Zooty and Rebo are 15 years old now and are starting to show some wear and tear. Rebo is recently on blood pressure medication (older kidney problems led to high blood pressure which led to thickening of the heart wall which lead to a heart murmur); Zooty is hyperthyrodial.

Kidney and thyroid problems are common in housecats. You know when you see your vet and they ask you questions about whether your cat’s behavior has changed recently? If it has, that can be a symptom of thyroid problems. Hyperthyroidism cranks up the cat’s metabolism and can lead to things like 3AM yowling, vomiting and general hyperactivity.

It’s most commonly caused by benign tumors on the thyroid gland. Less commonly the tumors may be malignant, but we’re hoping that in Zooty’s case they’ll be garden variety benign.

It turns out that thyroid tumors are one of the few kinds of cancer which can be treated easily. Thyroid tissue absorbs iodine, which makes it very easy to target. The common treatment is to inject cats with a radioactive isotope of iodine, I-131, which, as it’s taken up by the thyroid tumors kills them. It’s a very neat (as in, not messy) treatment, normally with few side effects. And statistically, cats that go through I-131 treatment have been mortality than cats that are left untreated or cats that use medication to control their thyroid levels.

The interesting thing is that at the end of the week (assuming all goes well) we will be taking delivery of a radioactive cat. He’ll need to be isolated from his non-radioactive brother for two weeks. And his radioactive waste will need to be stored for about three months until it cools down to the point where it can go into landfill.

From what I’ve read, treatment is usually harder on cats’ owners than the cats themselves. The clinic that’s treating Zooty offers online webcams, so we can take a peak during the next few days.

IMG 3127 Down One CatScreen Shot 2013 03 18 at 12.15.20 PM Down One Cat

The first photo is pre-I-131 Zooty… the second is radioactive Internet cat!

link

navigation
[ viewing | most recent entries ]
[ go | earlier ]