Code and things

Text

Today, my IT guy told me that I had to move my machine from one AD domain to another.  Nothing could go wrong.

Well, that’s the furthest thing from what happened.  Everything melted.  Luckily, I had everything backed up via Crashplan.  Most of everything that I needed, I was able to retrieve instantly.  I had put all of my SSH keys on flash already and all the rest was backed up via Crashplan. Except for my “mysrc” repo, where I keep all the stuff that I’m working on.  Most of this is on my public github or private, internal gitolite installation.  That’s fine and all but I don’t want to have to go and rip all of those repos again.

So I wrote this little Node.js script to clone all my repos from Github.  Run it in your ~/mysrc folder or where ever you want them. Oh, and if you use this, please change the username in the path.

Text

For the last year or so, I’ve been working on reading through Secrets of the JavaScript Ninja by John Resig and Bear Bibeault.  The book isn’t published just yet, it’s going through the MEAP process over at Manning.

While you may think that taking a year to read a book is a little wrong, it’s been well worth it.  Every few paragraphs, I discover something completely amazing.  Also, I’m not just reading, I’m working along with the book. I’m trying to immediately apply the concept before moving on to make sure I understand what’s going on.  I’ve put a copy of all the samples up on a Git repo.  

Tonight, while working through the chapter on Regular Expressions, I saw that you could define a repetition on a set of characters. My gears started turning and I thought about a common issue which is rational number representation.  Often times, when representing a rational number in some system, such as decimal or even binary, you can not represent it completely. For example, 1/3 = 0.3333333333… 

All of a sudden, I thought of a solution to check for rational numbers that can not be represented finitely. I don’t think I’ve ever needed this, however, I got a complete rush out of it. Check it out:

Update: My good friend, Lex, mentioned that I should leave the regex boundless. I used to have `var pntdrrn = /\d{5,9999}/;` and now I have `var pntdrrn = /\d{5,}/;`

Simple, helpful CORS bypass via Node.js

Text

Occasionally, I need to use jQuery on a page that I’m browsing. To do that, I use Karl Swedberg’s awesome jQuerify Bookmarklet.

Today, I needed to Underscore.JS. So, I took his and extended it to work with Underscore. 

Behold, Underscorify.

Text

PhoneGap 2.0 has a lot of awesome improvements, especially the command line tools for building and launching.  

I wasn’t able to figure out how to use their “emulate” script to trigger into an iPad, however, looking inside of the “emulate” script they give you, I saw that they’re just using the ios-sim project ( which you had to install during setup ). The PhoneGap has a tool called ios-sim which is a fork from the (defunct?) iphonesim project 

You can spawn the emulator directly into iPad mode like such :

ios-sim launch ../build/{{ your_app_name }}.app/ --family ipad 

XCode-free, the way to be.

Text

Last night, I watched a video called “JavaScript: Enter the Dragon” by Dmitry Baranovskiy. In the video, he spends some time discussing the concept of bodybuilding and compares it to JavaScript development: many think they look like an “Arnold” but, compared to the true form of beauty, the Greek “ideal”, they are truly wimps. Being an art history nerd, I really liked the analogy. 

He then went on to discuss some important concepts of JavaScript development, such as the number of types in the language, closures, type coersion, prototypal inheritance chains and what happens when you begin to manipulate the prototype of ancestors, etc. 

Some of the stuff that I saw I knew. I could teach someone else. But a few things I completely failed on. While some would say “you never have to know such things”, I would say that you’re wrong. The reason that I say this is because while learning some more last night, I saw tons of stuff in some of my code that is absolutely worthless. 

Dmitry also mentioned the fact that most people suck at JavaScript. His slang reference to the concept known more technically as the Dunning-Kruger effect wasn’t lost on me and I saw how once again, I thought I was smarter than I actually was. The code examples that followed for the next few minutes demonstrated to me that I don’t really know JavaScript.

Now, to be fair, we need to verify terms here: I’m not saying that I can’t make web applications using the language called JavaScript. I definitely can. What I’m not very good at is language syntax and concepts. 

Here’s a little question that he posted this morning:

Well, it equals 0, and I have no idea why that’s the case… 

But I’m on a mission to change that.

Text

If you haven’t heard of MemSQL yet, this post won’t really matter to you…

MemSQL is claiming to be “wire-compatible” with MySQL (bottom paragraph on http://memsql.com/). I have no idea what MemSQL means by that, but as I understand their demo / getting started pages to be written, it seems that they are saying that you can drop in MemSQL, load up your schemas, load up your data and point your MySQL client to connect to MemSQL and no one will be the wiser.

Having a number of applications at work that I’m supporting and developing that use MySQL and MySQL connectors, this seemed like a holy grail.

I was extremely skeptical but I decided to spin up an Ubuntu 12.04 LTS install with 8Gb of memory. I installed mysql-client and mysql-server. I loaded up the MySQL sample Sakila schema and then loaded the data. Great, mysql is ready to roll.

I downloaded and setup memsql and attempted to load up Sakila and got this issue:

memsql> source ./sakila-schema.sql;
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK (0.00 sec)

Query OK, 0 rows affected (0.07 sec)

Database changed
ERROR 1286 (42000): Unknown storage engine 'InnoDB'
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1286 (42000): Unknown storage engine 'InnoDB'
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1286 (42000): Unknown storage engine 'InnoDB'
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'Fulltext indexes' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE TRIGGER' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE TRIGGER' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE TRIGGER' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1286 (42000): Unknown storage engine 'InnoDB'
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'REFERENTIAL ACTIONS' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE VIEW' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE VIEW' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE VIEW' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE VIEW' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE VIEW' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE VIEW' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE VIEW' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'TEMPORARY tables' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE PROCEDURE' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE PROCEDURE' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE PROCEDURE' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE PROCEDURE' is not supported by MemSQL.
ERROR 1706 (HY000): Feature 'CREATE PROCEDURE' is not supported by MemSQL.
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Apparently, the MemSQL team and I have completely different understandings of what “wire-compatibility” means. Here’s the list of things that aren’t supported:

  • Views
  • Prepared Queries
  • Stored procedures
  • User Defined Functions
  • Triggers
  • Foreign keys
  • Charsets other than utf8

One would think that the MemSQL team would disclose that they didn’t support InnoDB tables. Doing a search on their developer site for the term “InnoDB” doesn’t reveal any such information.

Also, it is clear that they believe that MemSQL will be a drop-in replacement for MySQL, as the MemSQL developer guide says to transition over to MemSQL is as simple as this:

To transition your application, simply change the connection credentials to point to MemSQL.

Unless I’m missing something huge, “shenanigans”, I say. The MemSQL team should publicly clarify what they mean by “wire-compatible”.

Text

While working on a few responsive web design implementations, I found a really interesting bug:

Let’s say you use the same image for “normal” displays and Retina displays and down-sample (set it’s width / height to be .5x of actual image), during DOM reflows / paints, certain browsers (Chrome, et al.) won’t anti-alias the image until the animation / reflow has stopped. This leaves the image looking “artifacty”, even thought it’s extremely resolute.

If you want the browser to aggressively anti-alias the image, just write a rule such as

.retina { transform: translateZ(0); -webkit-transform: translateZ(0); }

And then add the “retina” class to every image that is high resolution.

Oh, and for the love of everything, DON’T use “*” as your selector for that translation hack. You’ll absolutely destroy rendering performance.

Text

Rob Tarr kicked off the next session with an introduction with some development tools:

Ben Callahan spent some time talking about the implementation process:

Write the Markup:

  • fluid presentation makes the separation of style from content critical
  • he highlighted semantic.gs over against getskeleton.com
  • take the design and sketch-up / annotate the design choosing which tags communicate the semantic understanding of that part of the design

Base Styles and MQs:

  • make some base styles for the mobile-first 
  • start considering how to restyle the content as we expand

Lots of code was written. And it was golden.

They didn’t really dive into images or assets, as today was primarily concerned with front-end issues.

Ben wrapped up with the whole idea of the Responsive Mindset.  Maybe the techniques are important but what’s really important is the mindset behind the techniques.  Maybe it’s not so important to do it in the “responsive” way, but rather, we need to have everything in perspective to support all the devices. 

There was an after party and it was, apart from some really weird chick, really chill and awesome.  Major props to the Sparkbox Crew

More @brworkshop branding… Love this stuff. #brworkshop

More @brworkshop branding… Love this stuff. #brworkshop