Posts

So you’ve learned a few HTML tags and the basic structure of an HTML document. Now what? Since HTML adds meaning to content, the basis for all these suggestions is “find some interesting content and add meaning.” Really, anything that gets you in your editor or browser playing around with this stuff is going to be useful. Pretend you’ve been hired to make a web page for a company or nonprofit. Designers will often do this to build their portfolio.
2013-03-29
2 min read
I gave a 10-minute intro to table_print at ChicagoRuby this week. The video turned out nicely, check it out in the ChicagoRuby video archives! All the lightning talks from the evening are in a single video, but I’m up first.
2013-03-07
1 min read
Imagine: you open a rails console and type User.limit(100). The output shows your database call, then… ACTIVE RECORD GUT PUNCH!!! Your screen is overrun with an inscrutable wall of text. I hated it. I had some coping mechanisms, but they were cumbersome. For example, the map-and-print: puts User.all.map { |u| "#{u.id}, #{u.email}, #{u.bio}" }.join("\n"); 0 This still sucked. Tons of typing, mid-line typos, forgetting to start with ‘puts’, accidentally returning the whole array - and the output was better but still not great.
2013-02-22
3 min read
From https://stripe.com/blog/stripe-checkout: It’s unfortunate that everyone has to reinvent the wheel when the time comes to implement a payments UI. We decided to build something that you can just drop in as a single tag The script tag creates a “buy” button on your page. Clicking the button pops a modal payment form where the customer submits their info directly to stripe. It’s a literally a 30 second integration. But here’s the kicker:
2013-02-20
1 min read
UPDATE: I made a gem! Just add gem "marco-polo" to your gemfile to see your app name and environment in your console prompt. I hate when I have a bunch of consoles open and I don’t know which one is local, which is staging, and which is production. I could potentially do a lot of damage by using the wrong one. I find myself typing Rails.env over and over, to figure out which environment I’m in.
2013-01-21
3 min read
It’s easy to let CSS get out of hand and it’s hard to really take advantage of the cascade. Here I’ll explain some techniques that help stem CSS bloat. When you aren’t disciplined with your CSS, it’s easy to end up in a situation where it’s hard to… know what parts of the site a particular rule is acting upon know whether a given rule is ever used be confident your changes won’t clobber something on the other side of the site define rules with appropriately specific scopes find all the rules acting on a particular element A well-defined CSS structure addresses some of these problems.
2013-01-07
3 min read
(Note: if you aren’t using jasmine and jasmine-jquery to test your javascript go take care of that) Suppose we’re working on a sliding tile game, and we want to log the moves a player has made. We could create a Logger object to collect the moves, and use a callback in the Game method to update the logger. One of the simplest ways to implement a callback is with standalone function: Game.after_move = function() { for (var i = 0; i < this.
2012-12-17
3 min read
I don’t know the purpose of a rant about a hosting provider except to vent my own frustrations, so I’ll keep this quick. Here’s a step-by-step list of the reasons this blog is not on Bluehost: During checkout, I was never shown a total amount for my order - just a monthly price. It wasn’t clear whether I would be paying up front or be charged monthly. I left a field empty, and when the page reloaded to ask me to fix it, I was also switched back to the most expensive hosting plan.
2012-12-09
2 min read
The Problem This technique came from my work on table_print, an irb tool for showing ruby objects in tables. I wanted to let people configure its output on a process-wide basis; eg, a default date format so sll their dates are shown consistently in the way they prefer. Additionally, I wanted a simple, easy-to-remember interface and a clean global namespace. The Solution Here’s a basic syntax example for table_printing: # prints all the authors, along with their book titles and photo captions > tp Author.
2012-09-10
3 min read
Pulled this out of a talk by Avdi. This technique is described at 16:00 in the video. It’s nice for the user of a library to be able to catch any error coming out of the library, but at the same time, it’s nice for a library to pass through basic error types like HTTPError. To solve the problem, you can “tag” the HTTPError with your own error class, essentially raising both types of error:
2012-06-14
1 min read