
Tag: programming
Resources.co Blog Posts
It’s been nearly a year since I blogged here, but I’ve made a few posts to the Resources.co blog:
Bizarro JSON
Estimation
A poorly estimated programming task doesn’t just take longer than the estimated time. It also tends to takes longer than it would have taken if it were properly estimated, and is much more likely to not get done properly or to not get done at all.
jschain: angular directive and a test (#15)
I built a random-color angular directive with a test on the same page. I started by using plunkr but gave up and used Bower because my connection was unreliable. I learned that angular-mocks is a counterpart to Jasmine in that it exports global variables for convenience. Also, angular-mocks must be loaded after Jasmine. I learned this the hard way.
jschain: converting strings to and from binary (#14)
Encoding to binary:
'hello'.replace(/./g, function(c) { function pad(n) { return (n > 0) ? ('0' + pad(n - 1)) : ''; } var s = c.charCodeAt(0).toString(2); return pad(8 - s.length) + s; });
Decoding binary to a string:
'011101110110111101110111'.replace(/.{8}/g, function(s) { return String.fromCharCode(parseInt(s, 2)); });
jschain: invert-markdown (#13)
I made a little prototype of a literate programming tool inspired by Literate CoffeeScript. It converts markdown to JavaScript by turning markdown lines into comments, and JavaScript to markdown by removing comments around Markdown and putting fences around the JavaScript. It’s a little flawed right now.
jschain: tests (mocha/chai) inside jsbin (#12)
I found Mocha and Chai on cdnjs and created a small example of running them inside jsbin.
jschain: meanjs (#11)
I like building up a project from small parts but sometimes it’s good to try using a full framework to see what parts I’m missing. Today I tried starting a mean.js app with yeoman. It comes with a lot preconfigured, including five different authentication options, and since I chose it, an articles model. I removed four of the five authentication modules and changed the name of Article to Bin. In the process I found where things are stored in mean.js. It seems to do a good job of following the rails mantra of Convention Over Configuration.
- The Code (unfinished, and most of it isn’t mine, the commits show what I did)
I want to return to this experiment and get it working the rest of the way and deployed on Heroku. The basic idea is a minimalistic jsfiddle.
jschain: map with d3 (#10)
I used d3 to make a map. It was good practice. I had forgotten how d3?s chaining API works. When a function mutates an element, it returns the same element back. When a function appends something to an element, it returns the new element back.
I also tried using patterns in svg. I still have to learn some more to understand them and to get the results I want, and I also need to brush up on biezer curves.
Update: I adjusted the vertical offset of the pattern to remove gaps between states.
jschain: fabric, doge (#9)
Today I checked out Fabric.js. The basics are surprisingly quick to learn!
jschain: grunt, unindented (#8)
A lot of node programmers like to code on the left margin. This is made possible by JavaScript’s dynamic nature. Prototypes can be built up and exports.
In Grunt the examples and virtually all code are wrapped up in one big function. Gulp doesn’t require this, and I’m under the impression many prefer this. However Grunt has a huge standard library.
I like code that doesn’t leave the left margin for long because it’s easier for me to see chunks of code. It also allows me to interleave code, which sometimes makes a lot of sense.
Using OOP, Grunt can be made to have this style. I took the Gruntfile for jquery and made it stay to the left margin while working the same way.
I won’t be sending a pull request, but I may do this on one of my own projects.