サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
Pixel 9
avdi.codes
Enough With the Service Objects Already Skip to entry content Once upon a time I was writing a web app that needed to accept notifications of payments. Once it was notified of a payment (via a webhook) it needed to take certain actions to fulfill the purchase. An overweight controller Imagine that you’re working on this app. The payment notifications come in the form of PayPal-style IPN data. Here
Riffing on `interpose` implementations in Ruby Skip to entry content I very much enjoyed Brian Cobb’s step-by-step translation of the Clojure interpose function to Ruby. I too agree that interpose would be a handy method to have around. As a quick TL;DR: interpose is kind of like Array#join , except that it produces a sequence instead of a string. [1, 2].interpose(:sep).to_a # => [1, :sep, 2] Br
Look, let’s face it: Ruby tools are terrible. If you’ve worked in any Lisp you know what I’m talking about. If you’ve worked in Java or C# anytime recently you know what I’m talking about. If you’ve worked in Haskell you know what I’m talking about. “But Avdi! Lisp is homoiconic, and those other languages are statically typed! That’s an unfair comparison!” Well, if you’ve worked in Smalltalk you d
Let’s say we’re dispatching events to listener objects. Events look like this: Event = Struct.new(:name, :source, :args) Events should be routed to different handler methods based on the name of the event. For instance, when an object is sent the #call message with an :accepted event: listener.call(Event[:accepted, obj]) …then it should be dispatched to the #handle_accepted method, as if the liste
A personal programming language roadmap Skip to entry content Lately I’ve become increasingly sensitive to how little time I have left to learn new technologies. It’s not that I’m nearing death: I’m not, at least not by 21st century baseline human standards. It’s more a matter of the impossible and ever-expanding variety of tech that is out there to be learned. That, coupled with the limited time
The other day I put an app in production with (gasp) no automated tests. I’m careful to say no automated tests, because of course I had been testing it manually throughout the ~12 hours it took me to write the initial version of the app. In lieu of tests, I made sure to log copious amounts of information, which I then collected from my deployed app into Papertrail. For a single day’s work this was
Rake is ubiquitous in Ruby-land, but its power is often under-appreciated and under-used. Over the course of the past two weeks I’ve been posting a series of RubyTapas videos I did on Rake. They go into advanced features of Rake that can help you elegantly automate common tasks. Here, for convenience, is a list of all of the episodes in one place. I’ve included links to the original posts, which c
Follow me for updates on what I am creating.
I am thrilled to announce that my book Confident Ruby is now finished. I even hit my target of releasing by September 1st… if by “September 1st” I had meant “of the following year”. So what is this book and why should you buy it? Confident Ruby is, first and foremost, a book about joy. It’s about the joy I found when I first discovered how elegantly and succinctly I could state problems in Ruby co
A List of Programming Screencast Series Skip to entry content UPDATE: This list is now very out of date. Please check out the updated version instead. Since I publish a screencast series, I’m curious what other programming screencasts people watch. So I asked around. Here’s the list, based on feedback as well as my own bookmarks. Railscasts – Ruby on Rails Destroy all Software – Ruby, Python, Unix
Linux has better hardware support than OS X Skip to entry content TL;DR: OS X users pick their hardware from a very short list of known-good configurations, and when you do the same thing for Linux, the results are equivalent. Like most nerds I know, I don’t mind disagreement, but something in me just can’t stand a poor argument. And thus it is that I feel compelled to write about one such argumen
Let’s stop telling programming newbies to learn Vim (or Emacs) Skip to entry content As readers of this blog know, I am a proud user of the third most baffling editor in existence. (Why third? well, I feel confident placing Vim as the 2nd, because while inscrutable, hand-twisting keybindings are difficult, in my observation modal editing is a slightly bigger mental leap for the programming newbie.
Configuring database_cleaner with Rails, RSpec, Capybara, and Selenium Skip to entry content If you write Rails code, or any Ruby code that interacts with a database, and you also write automated tests, chances are you have heard of or used the database_cleaner gem. It’s a terrific gem that abstracts away the various ORM APIs for getting the DB into a “blank slate” state. Periodically I start a ne
If you’re reading this, you have my permission to nag me to write up an actual post about why I’m no longer distributing Objects on Rails. In the meantime, feel free to sign up for my free email course about how most of what they told me about object-oriented programming was wrong: Lies of Object-Oriented Programming in Ruby and Rails
I’ve been getting some emails from young developers wanting to “level up” as programmers. I’m definitely not the first to write about this topic, so I’m not sure how much I have to add. Still, for what it’s worth here are a few points off the top of my head: Work with other developers. We are at a wonderful time in the history of technology when for the first time, it doesn’t really matter where y
Thank you to Ben Hamill for sending me a question that prompted this post. Very often in Ruby code, we would like to execute some action only if an object is present: def slug(title) if title title.strip.downcase.tr_s('^[a-z0-9]', '-') end end slug(" Confident Code") confident-code h = {} slug(h[:missing_key]) nil Strictly speaking, we aren’t checking for object presence here. In Ruby there is alm
When spec-ing something that calls method which takes a set of nested hashes (as many Rails methods do), it may be tempting to use #hash_including: to test for only the values you care about. However #hash_including won’t work the way we might hope for nested hashes. Take the following (highly contrived) example: describe CoffeeMaker do before :each do @it = CoffeeMaker.new end it "should receive
Rails 3 resource routes with dots; or, how to make a Ruby developer go a little bit insane Skip to entry content This one cost me at least an hour of frustration. So apparently the Rails router has considered the dot (“.”) to be a “separator” character along with the slash (“/”) since version 1.2. I don’t know in what context this ever seemed like a good idea, but whatever. It’s not the sort of th
UPDATE: For a newer, better take on this topic, check out this post. UPDATE 2: This topic is part of the Graceful.Dev Flawless Ruby course, which is now completely free! If you use Ruby long enough, you will discover the and and or operators. These appear at first glance to be synonyms for && and ||. You will then be tempted to use these English oprators in place of && and ||, for the sake of impr
Hammertime: An interactive error console for Ruby Skip to entry content Users of Lisp and Smalltalk environments are used to having some pretty powerful tools for debugging exceptions in their code. For instance, here’s the dialog I see when I try to do execute some bad code in Squeak: Ruby users are not so lucky. Our first indication of an error is either the code not working or a stack trace, de
このページを最初にブックマークしてみませんか?
『Avdi Grimm, Code Cleric』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く