weblog.jamisbuck.org Archives - 28 June 2016, Tuesday

  • Buckblog: Think You’re Failing? Look Around.

    weblog.jamisbuck.org 14 May '16, 11pm

    Think You’re Failing? Look Around. 14 May 2016 — A recent article by the author about seeing past our "failure filters" — 1-minute read It’s not tech-related , but I think it might just be career-related . I posted an article on Medium today about finding perspective when it feels lik...

  • Buckblog: Tapping ActiveRecord Relations

    weblog.jamisbuck.org 23 Apr '16, 9pm

    (Yes, I know I said I was probably not going to write here anymore, but while I like Medium for long-form articles, it didn’t quite fit the bill for posts that wanted syntax highlighting. Thus, I’ll probably continue to use the Buckblog for technical articles, and Medium for long-form.)

  • Buckblog: Introducing the Query Composer

    weblog.jamisbuck.org 26 Mar '16, 4pm

    Despite that, I’ve put together an example, using a hypothetical library administration system: Libraries have Books and Patrons, Books have Topics, and Patrons may borrow Books. The example, then, builds and runs a report that asks how many books each patron borrowed during some peri...

  • Buckblog: The Poverty of Constraints

    weblog.jamisbuck.org 19 Mar '16, 5pm

    Let’s reinterpret some Korean proverbs as software advice. (Two previous posts in this vein are “Software Proverbs ” and “The Weakly-Flowing Stream ”.) The two I’ve selected today share a theme, that of “poverty”, which can be viewed in terms of constraints . First: “가난한 집에서 효자 난다.” A...

  • A church billboard inspired me to write a Ruby script.

    Buckblog: Variations on a Theme: "I Becomes We..."

    weblog.jamisbuck.org 12 Mar '16, 4pm

    I was in Oregon last week, staying with my aunt and uncle, and on the way to their place I passed a church with a sign that read: When I becomes we, illness becomes wellness Now, normally I really like pithy little sayings like that. I love playing with language, and discovering insig...

  • Buckblog: Being a Good Neighbor...

    weblog.jamisbuck.org 05 Mar '16, 3pm

    Disclaimer: this post is a departure from my usual fare. No computers, no code, no programming. It’s intended primarily to help me process a rather painful, frustrating, and complicated episode in my life, and may or may not have any particular relevance to you. Years ago, when I live...

  • Implementing a "bloom" effect in Swift+Metal:

    Buckblog: Implementing a Bloom Effect with Swift+Metal

    weblog.jamisbuck.org 27 Feb '16, 7pm

    I’ve been learning a lot about Apple’s Metal framework recently, as I’ve been working through building a game based on navigating mazes on non-planar surfaces (cylinders, mobius strips, etc.). It’s been a lot of fun, but it’s also been pretty frustrating. Metal is still pretty new, so...

  • Buckblog: Don't Feed the Hamster the Whole Stalk

    weblog.jamisbuck.org 20 Feb '16, 9pm

    The bellow was answered–from across the house–with a sigh, as Fabian stopped scrubbing the floor and sat back on his ankles. It never failed. Right in the middle of the fall cleaning. He rubbed his eyes and wiped suds from his goatee, counting. six…seven…eight… “Fabian!” Fabian nodded...

  • Buckblog: The weakly-flowing stream

    weblog.jamisbuck.org 13 Feb '16, 9pm

    There’s a (possibly obscure) saying in Korean: “가늘게 흐르는 개울물도 바다로 간다.” Literally, it means “even the waters of a weakly-flowing stream go to the ocean.” From about the 5th grade until I graduated high school I lived in a small town on the Oregon coast. That was almost 25 years ago now,...

  • "Living With Your Eyes Open"

    Buckblog: Living with Your Eyes Open

    weblog.jamisbuck.org 06 Feb '16, 11pm

    6 February 2016 — The author shares some experiences in which learning came completely by surprise — 6-minute read A couple of years ago, I was struck by how much there was to learn. I tweeted this: The more I learn, the more I'm convinced that there's nothing that can't be learned. —...

  • Buckblog: Software Proverbs

    weblog.jamisbuck.org 30 Jan '16, 7pm

    When I was in Korea (20+ years ago), I picked up a little book called “속담백과”, which could maybe be translated as “The Proverb Encyclopedia”. It was a fun exploration of hundreds (thousands?) of Korean proverbs, all in Korean. I worked through a few pages of the book when I was in Kore...

  • Buckblog: Mazes in Swift

    weblog.jamisbuck.org 24 Jan '16, 2am

    I did it a bit differently this time. Instead of looking at existing code, I went a bit meta and instead read through The Official raywenderlich.com Swift Style Guide . I knew, going in, that a style guide was going to be a pretty opinionated document. For instance, if I were to read ...

  • Buckblog: A Pretty-Printer for SQL

    weblog.jamisbuck.org 16 Jan '16, 10pm

    Lately, I’ve been up to my elbows in enormous SQL queries. I can’t share the details, but suffice to say that it’s for a reporting app, and the SQL for these queries frequently run as much as 50,000 characters each. This happens because the queries are built up modularly, with each mo...

  • Don't Assume It's Difficult Until It Is

    Buckblog: Don't Assume It's Difficult until It Is

    weblog.jamisbuck.org 09 Jan '16, 9pm

    Does a task look like it might have some difficult or challenging bits? Don’t be too hasty in drawing that map. Your assumptions almost certainly have some gaping holes in them. About twenty years ago I returned home from a two-year stay in South Korea, where I had served as a mission...

  • This side-project has been so much fun to work on:

    Buckblog: Game Demonstration: Recover the Widgets

    weblog.jamisbuck.org 02 Jan '16, 8pm

    The THREE.js sample code I used to start experimenting (yay! a rotating cube!) used a field of view of 75 degrees. I continued using that for a while, but eventually found the slight fish-eye effect a bit disorienting. I went down to 45 degrees for a few iterations, but that turned ou...

  • Buckblog: Avoiding "Call Super" with Callbacks

    weblog.jamisbuck.org 19 Dec '15, 4pm

    is situation in which a superclass requires that subclasses invoke super when overriding a method. Martin Fowler is, I believe, among the first to have labelled this an anti-pattern (“minor code smell”, in his words), and he’s careful to point out the problem is not with the super cal...

  • Buckblog: Little Things: Introspecting Block Parameters

    weblog.jamisbuck.org 12 Dec '15, 9pm

    Since I don’t yet have permission from my client to share the actual code I wrote, I’ll demonstrate this esoteric little feature by monkeypatching Hash and adding a using method. The end result will let us access Hash keys that match the names of the parameters we pass to the block, l...

  • Buckblog: Integration API vs. Internal API

    weblog.jamisbuck.org 05 Dec '15, 5pm

    These typically manifest as callbacks. Webhooks are one form of this. GitHub, for instance, lets you specify a URL which will be sent information when some event occurs (like a commit). Parsers also use this technique, allowing you to supply a set of callbacks to be invoked at various...

  • Upsilon Mazes

    Buckblog: Upsilon Mazes

    weblog.jamisbuck.org 28 Nov '15, 9pm

    This article is adapted from material that I had originally written for my book, Mazes for Programmers @amazon | @b&n . It was intended to be the last section in chapter 8, “Exploring Other Grids”, following a discussion of hex and triangle grids. In order to trim the length of the bo...

  • Buckblog: Little Things: Refactoring with Hashes

    weblog.jamisbuck.org 22 Nov '15, 1am

    Right? And when I see a case statement being used simply to select between different values given some input, I find myself itching to rewrite it using a hash. Because, really, what is a hash, except a mapping that selects between different values, given some input?

  • Representing toroidal grids and mazes

    Buckblog: Representing a Toroidal Grid

    weblog.jamisbuck.org 22 Nov '15, 12am

    Toroidal grids share a lot with spherical grids (pg. 238 of my book), so some of this may sound very familiar if you’ve been through that. A spherical grid is basically a soup-can wrapper rolled so the east and west edges touch (and then with a bit of magic applied to the north and so...

  • Buckblog: The Dynamic Def

    weblog.jamisbuck.org 17 Oct '15, 8pm

    If you need justification for this, try a simple benchmark script. It turns out that using a nested def for memoization results in a memoized method that is about 30% faster…but honestly, that’s not saying much. Both techniques are pretty blazing fast. On my computer, 500k iterations ...

  • Buckblog: Bulk Inserts in ActiveRecord

    weblog.jamisbuck.org 10 Oct '15, 9pm

    Each item is added to the queue, and the whole is accumulated into a single insert at the end of the block. (For lots of rows, it might not actually be a single insert statement, though. Some backends, like SQLite, don’t like you to insert more than some number of rows at a time. For ...

  • Buckblog: Bulk Inserts in ActiveRecord

    weblog.jamisbuck.org 10 Oct '15, 8pm

    Each item is added to the queue, and the whole is accumulated into a single insert at the end of the block. (For lots of rows, it might not actually be a single insert statement, though. Some backends, like SQLite, don’t like you to insert more than some number of rows at a time. For ...

  • Buckblog: Changing the Channel

    weblog.jamisbuck.org 04 Oct '15, 2am

    Stuck? Try changing the channel. No, seriously. It’s like if you’re watching TV and you’re feeling uninspired by what you see, you change the channel. This doesn’t change the TV at all–you’re still staring at the same screen, in the same plastic chassis–but now you’re seeing something...

  • Generating Word Search Puzzles

    Buckblog: Generating Word Search Puzzles

    weblog.jamisbuck.org 26 Sep '15, 2pm

    My daughter (age 11) was writing an article this week for a local student newsletter , and had the idea to include a word search puzzle . After spending ten minutes looking online and being fairly disappointed in the quality of what we found, I decided to take a stab at writing a word...

  • Buckblog

    weblog.jamisbuck.org 19 Sep '15, 9pm

    Most of you will be familiar with “default scopes” in ActiveRecord, the feature that lets you apply conditions automatically to all queries on a given model. For example, suppose we have a system where a blog author can be deleted (perhaps to remove their access to the blog), while pr...

    Related:
    1. Buckblog weblog.jamisbuck.org 19 Sep '15, 8pm
  • Buckblog

    weblog.jamisbuck.org 19 Sep '15, 8pm

    Most of you will be familiar with “default scopes” in ActiveRecord, the feature that lets you apply conditions automatically to all queries on a given model. For example, suppose we have a system where a blog author can be deleted (perhaps to remove their access to the blog), while pr...

    Related:
    1. Buckblog weblog.jamisbuck.org 19 Sep '15, 9pm
  • Buckblog

    weblog.jamisbuck.org 13 Sep '15, 2am

    This leads to a quirky (but oh, so useful!) little thing about heredocs: syntactically, the first delimiter represents the entire heredoc . That is to say, if you want to invoke a method on the string, you attach the method invocation to the first delimiter, not the last! Like this:

  • I love how Ruby makes hashes and (arity-1) procs duck-type-compatible:

    Buckblog

    weblog.jamisbuck.org 06 Sep '15, 3am

    A few years ago, I gave a presentation at Mountain West Ruby Conference entitled “It’s the Little Things” , in which I described “some of the littlest things that make Ruby big”. The point of the talk was really to highlight some of my favorite features of Ruby, and to emphasize that ...