Optical Illusions on Canvas

I’ve always loved optical illusions. Anything, really, that reminds me that I am not my brain.

I recently came across a old, great illusion that I have loved and have always wished that I could tweak to find out what point I start to lose grasp of the circles. I built a visualization in JavaScript (original static image) using canvas today that allows you to alter the properties of the circles, sizing, and rotation and it allows you to do just that.

The key to the illusion is the alternating rotation of the squares in each circle guiding your eyes in conflicting directions making you visualize separate spirals. If you uncheck ‘alternateRotation’ you get a more subtle illusion of one attached spiral, which is still cool.

Concentric Circle Illusion in JavaScript on Canvas

Running jasmine through phantomjs : grunt-jasmine-runner

I just pushed up a release of an internal runner I’ve been using for several weeks now. It started as a fork of @creynder’s grunt-jasmine-task but grew well beyond any appropriate scope of a pull request and figured I needed to take on the responsibility of maintaining it.

grunt-jasmine-runner [source]

There is base documentation at the source and the configuration is pretty straightforward. I put together an example application here : example grunt jasmine configuration

There is still a lot to come, but this was the best release point to prevent feature-paralysis.

Todomvc with Backbone.Marionette + Requirejs

I recently completed an app I’m planning on using for JavaScriptU in october and wrote it in the style of Addy Osmani’s TodoMVC repo so that it can be more easily compared to other frameworks.

Backbone.Marionette + RequireJS TodoMVC (source)

It differs a little bit in the style I would normally adhere to in order to make it as simple as possible for the sake of easy comparison. I tried to inject as little of my own bias in it as possible, except for very small file sizes and global jQuery and underscore.

Bringing back the food

The fifth day was enough for me to realize that my ability to lead a comfortable life in the routine I didn’t want to alter was being hampered. My motivation for work was drained, my speech was peculiarly off, and my fatigue levels were high.

The morning of the sixth day I weighed in at 169 pounds even, for an 11 pound loss. I’ll update some time later as to how much of that was put back on and how quickly.

I’m positive that there were numerous factors on top of eating that contributed to the poor feeling towards the end, but not eating affected my ability to regulate other stresses. My fatigue levels were higher than normal due to a hot and sweaty toddler who wasn’t sleeping well combined with a new standing desk at work. One change that didn’t occur to me until much later than it should have was that I almost never took breaks at work when food was cut out. I didn’t take a lunch break, I didn’t take coffee breaks, drink breaks, random breaks, I just stood and worked nearly the entire day. That alone, even while properly nourished, is going to lead to fatigue and decreased motivation.

My diet will likely be permanently affected. I liked the feeling I had earlier in the week, it was almost like freedom. Freedom from food. Since I no longer intend to eat as little as I can stomach (literally), the experiment is over at about 133 hours in (five and a half days).

Day 5 and first doubts

I woke up feeling like crap today and mostly attribute that to my son kicking me in the face all night, but it is definitely compounded by not eating and probably the fact that my wife was cooking bacon this morning, a smell that is still intoxicating. I took a bite, I’m only human.

I weighed in at 170.8 for a 1.2 pound loss.

I ate a handful of raw baby spinach (20 cal)  and had one small bite of bacon (approximating 1/5th a slice, 9 cal)  to see how that would kickstart the day. It did reasonably well but at about 2:00 I started to lose focus and feel drained again.

My speech is something that is deteriorating as well. My ability to get words out and to recall words quickly enough to speak is noticeably lessened. I’m not sure if it’s yet noticeable to other people, but I definitely feel it. I’ll see how I feel tomorrow but if better sleep doesn’t remedy this then tomorrow may be my last day.

Some people have likened this experiment to the the master cleanse but the significant difference is the maple syrup in each glass of the drink accounts for a little over 100 calories. When 6-12 glasses are recommended a day, you are consuming 600-1200 calories to provide energy to your body, which is a lot!

For comparison, our current calorie tally:

  • ~63 calories for the two Buitoni ravioli (approximating a quarter cup)
  • 11 calories for the raw parsley (about half a cup)
  • 20 calories for 6 asparagus spears
  • 68 calories for two cans of V8
  • 350 calories for a little over 2 bottles of shock top (!!!)
  • 4 calories for a pistachio
  • 20 calories for 1.5 cups spinach (above)
  • 9 calories for a bite of bacon (above)
  • 40 calories of half and half (approximated) for small coffees
  • 4 calories coffee (2 8oz cups)
  • 2 packets sugar

That comes out to 591 calories over the past 5 days. Given 2600 calories being my recommended daily amount (choosemyplate.org), I’m averaging about 4% of my recommended intake and about 118 calories a day. Half of that consumption was centered around a 2 hour period, too. The last 2 days have seen around 50 calories total.

One thing I didn’t account for was how the sleep rhythm we have adopted in modern society is probably very counterproductive to hibernation mode and conserving limited energy. I can’t nap when I want and I need to force myself to stay awake for a significant portion of the day. Oh how I would love a nap.

Fooling around on app.net

I’ve flopped back and forth on whether or not App.net is a good idea and I think I’m solidly landing on the belief that it is great. Or at least not bad. I don’t know. Maybe.

Initially the thought of a pay-for social network sounded ridiculous but as I reevaluate the importance of social networks to me and the value I get out of them, it seems silly to let them be in the control of companies looking to sell your data and put ads in your face.

The part that concerns me is if app.net requires more money to run than they are pulling in. Are they going to charge more? Are ads inevitable? What if I can’t pay? Do I disappear?

Day 4 with a pistachio

I ate a pistachio today. It wasn’t really that worth it.

I weighed 172 pounds this morning, about 1.5 pounds down from yesterday which was expected, though my expectations have virtually no basis in any reasonable science or math.

Consistently the hardest part of this is the mood. It’s not depression or sadness, really, it’s just being kind of neutral. An overwhelming sense of “meh.” I do still feel joy and smile at things that make me happy, but my motivation for things like contributing (what I like to think were) witty comments to conversations has dwindled to near nothing. It’s probably a combination of energy levels and the lack of at-will snack intake throughout the day, but it’s one of the worst parts of this experiment.

Overall, energy levels are tolerable. I do occasionally have a hard time focusing my eyes, which is a new, unexpected, and not too awesome. I’ve been concerned about the need for glasses lately anyway so maybe this process is making that issue more apparent, or maybe I am slowly dying inside. Who knows? Probably doctors…

 

 

 

Beer on a very empty stomach

After the sandiegojs meetup last night, I went out with a few of the attendees for beers down the road, curious to see how my body would react to alcohol after not eating for 72 hours.

Turns out it’s no big deal. I had expected the old adage regarding eating food before drinking to mean that I would get dangerously trashed after one beer since there is almost literally nothing in my digestive system at all. I had two and a half ShockTop beers and after a couple hours at the bar I felt surprisingly normal and confirmed this by blowing a .06 on a personal breathalyzer*

I felt fine in the morning, if not better than I did the previous morning. I don’t know if that’s due to a shift in how my body is producing glucose, or if it’s the 350 calories and 40 grams of carbohydrates consumed the night before. It’s amazing how easy it is to disregard the nutritional values of beverages. 2.5 beers tripled my calorie consumption over the previous 72 hours.

So, as far as I’m concerned, eating before drinking is irrelevant. Since I generally want food after a few beers regardless, I’m going to wait to grab something until I’ve had a couple drinks from now on.

*Yes, I have a personal breathalyzer. It’s handy for experiments and settling arguments about who can drive!

A balance between AMD and vanilla JavaScript

My environments tend to be the most productive when I combine global variables with AMD modules and that bugs both the AMD crowd and the vanilla crowd.

I’m not shy about proclaiming my love for requirejs and AMD-compatible JavaScript modules, but sometimes they can suck the life out of me, too. I flip flop between wanting libraries like jquery and underscore as modules without global namespaces and then just wanting them available anywhere, at any time. On the one hand, they are used often and having to define them as dependencies is just an extra annoyance for something that should be considered convenient, and on the other hand you lose what modules actually are dependent on.

I also alternate between wanting to specify exact dependencies for each model vs depending on a module aggregator but then it ends up requiring you to depending on even more modules and the way to actually define those in AMD is kind of frustrating.

I can do write dependencies the commonjs way:

[cc lang=’javascript’]
require(function(require){
var Klass = require(‘Klass’);
});
[/cc]

Or the AMD way

[cc lang=’javascript’]
require([‘Klass’],function(Klass){
// Klass passed in as argument
});
[/cc]

Both ways require duplication. The CommonJS method requires you to build a series of variable definitions with function calls and the AMD method requires you to duplicate identical words and also maintain appropriate order.

If you end up defining every template or model you need for a module then you can get some lengthy dependencies. Anything over 4-5 dependencies becomes cumbersome to manage. When you explicitly add jquery & underscore to that dependency list then you only have 2 or 3 more modules you can really deal with happily and that’s not enough.

I wrote a quick grunt task (located on github: grunt-require-dir) to bundle up a directory of arbitrary files to a single file composed of require calls, allowing me to deal, at least, with dependencies based around subject. This allows me to automate the bundling of directories like templates or models into a single “aggregator” or “accessor” module. This removes my ability to know exactly what is dependent on what, but it provides greater flexibility to refactor and starts to bridge the gap (for me, anyway).

I’ve also started to think of jQuery, underscore, and Deferreds as features that are just part of my environment, essentially labeling them as global dependencies and having my modules use them as global variables. So sue me.

It’s also interesting to note that, with AMD and requirejs, your global namespace is significantly more pristine. So why avoid it? Why not have first class features of your application or framework occupy that space now? It’s not poisonous and provides loads of convenience. Use AMD where it benefits you and ignore it when it doesn’t.

Day 3 without food

I definitely had dreams about eating pizza last night and my stomach was rumbling when I woke up. I licked a spoon of some Activia light yogurt I served for breakfast out of habit and it tasted disgusting. I would guess it is due to losing a baseline expectation of sweetness with regular sugar and having artificial sweeteners just tasting foreign and effing horrible. I threw it away and made my son an omelette. Then I rinsed my mouth out and brushed my teeth to get the taste out of my mouth.

Recalibrating my tastes and lessening my food addictions are one of the desired outcomes of this diet. Craving a bowl of spinach vs a reese’s peanut butter cup will be considered one of the successes.

I weigh 173.6 pounds today which is a 2.4 pound loss, more than I was expecting considering I haven’t produced much waste. If that trend continues this experiment may be over sooner than I expected. I also tested my blood sugar today and it was at 83 mg/dl, which is a normal (overnight) fasting blood sugar level, but I’m not sure what normal would be at this point.

I do feel slightly more sluggish lately, not in a lazy way, but more of a “zen” or “chill” way, for lack of better words. I’m more likely to shrug things off, take things slowly, and chill on the couch. Again, it’s hard to tell what exactly is causing this since I did just move back to a standing desk at work so wanting to sit down and relax after 8-9 hours of standing makes sense.

About midday I started to feel off and down so I went to Sprouts and bought a bunch of parsley (45 cents worth). First bite tasted phenomenal, and after eating about a half a cup I started to feel better.

Calorie total by the end of Day 3:

Making our total 164 calories after 72 hours. According to standard armchair scientist sources, around the 3 day mark is when your body starts turning towards fat stores so am interested in the way I feel going forward. Maybe I’ve already hit that point.