Uncategorized

RubyNation 2013 In Review

RubyNation 2013 is done! Outside of un-confs like BarCamp, it was the first conf I’ve presented at. I was nervous, so I kept practicing and smoothing the slides, and I think that helped a lot – everyone seemed to like the talk. Thanks again to everyone who came to hear it!

RubyNation was a smaller conference. Someone said they felt as though you could almost talk to every attendee, or at least recognize them all by face. It felt comfortable and familiar. But I think there was more to that than just being small – I think the organizers made some particular choices that made it that way.

First, rather than rows of chairs, they provided banquet-style round tables with about 10 chairs each. This is really good for getting people talking: you have a handful of neighbors, and you’re all facing each other. It’s much more social than 2 neighbors and the back of someone’s head. It does mean that half the table has to turn around to watch the talks, but in practice, it wasn’t a problem. Whatever extra floor space the round tables took up was worth it.

Second, rather than catering lunch, each conf organizer paired with a speaker to lead the way to a different nearby restaurant. Attendees got to pick which group they would go with. Splitting into so many groups meant there was a good chance you’d eat your lunch chatting with a speaker or organizer. It also meant you had much more choice over what to eat. (Remember RailsConf 2012, when they served pot pies every single day?)

Rails Girls DC was there in force. I’m not sure, but I think this was the first time RubyNation was paired with a Rails Girls DC training day. It was great to see so many people new to the community, discovering ruby and programming, and I think the variety of talks must have complemented the more-focused training day very well.

For a first-time speaker, it was a very welcoming, laid-back group – though, as Sandi Metz helpfully warned me ahead of time, they might not laugh too loudly at your jokes. If you’ve never given a talk at a conference, try starting with RubyNation.

Standard
Productivity, Programming, Uncategorized

Ruby Scrubbing JavaScript: Raise Those Curly Braces

Of the Programmer Holy Wars, “curly braces on the same line, or the next line?” is not as vitriolic as emacs/vim or tabs/spaces, but it’s up there.

(Personally, I don’t care. I’ve done years with each style. You get used to it.)

In JavaScript, it’s less of an issue, because, when you put curly braces on the next line, JavaScript will (sometimes) automatically insert semicolons into your code. It’s well-documented and discussed, and understandable; here’s a question about it on stackoverflow.

Yesterday I reviewed some old JavaScript (circa 2007) that our web designer Daniel rehabilitated, and this concern came up. Rather than hunt around manually for dangling curly braces, I wrote some ruby to find and fix them.

# fix-js-curies.rb
ARGV.each do |filename|
  src = File.read(filename)

  # This multi-line regex looks for any { that
  # comes after a \n, and any tabs or spaces,
  # and replaces it with a space and a {.
  new_src = src.gsub(/\n[ \t]*\{/m, ' {')

  if src == new_src
    puts filename
  else
    puts "#{filename} fixed!"
    File.open(filename, 'w') do |f|
      f.puts new_src
    end
  end
end

You can pass it any .js files as command-line arguments:

$ ruby fix-js-curlies.rb app/assets/*.js

Props to Daniel: when I ran my script, it didn’t actually find any, because he got them all ahead of me.

Standard
Uncategorized

PSA: Connecticut Tech is Getting Exciting

New Haven Ruby is going strong, and New Haven JavaScript is heating up fast. We had a great turnout last night, with about 40 people at the Digital Surgeons office, and some great talks. Meet-ups are full of energy, introductions, and catching up with friends. And, obviously, tech talk.

broader New Haven tech community is emerging, combining NH.rb and NH.js with The Grove,  Independent Software, and now the A100 Developer Community.

The Greater Hartford ACM chapter is spinning up, and doing very well so far, hosting talks and tours of Connecticut technology centers. Hartford JavaScript is starting and Hartford Ruby is making a come-back (which I’m especially happy to see).

Connecticut hackers are doing some great things. Come out and join us!

Standard
Productivity, Software Thinking

Direct Manipulation, and Text Editors

Hat-tip to Giles Bowkett for mentioning Bret Victor’s talk, Stop Drawing Dead Fish, about direct manipulation and computer interaction as a tool for illustrators and animators.

I paused this video part-way through, so I could Get Down to Work. I paused it around 34:30, right after Bret Victor mentioned David Hestenes‘ idea that algebra and geometry help us model the world in similar ways, but that algebra uses our linguistic ability, while geometry uses our visual/spatial perception. Victor went on to say that tools for visual artists should use our visual/spatial abilities (direct manipulation), rather than our linguistic ones (code).

Like I said, it was time to Get Down to Work. I flipped over to Sublime Text 2, where I happened to have a block of text selected. Warming up, I idly hit command-I to search for a bit of text, only to realize that Sublime was only searching in that selected text. This is handy! I’ve been wanting something like this lately, when a method or variable name shows up all over the file, but I’m only working on one method.

Using the trackpad to select a bunch of text, and then working on it, feels a lot like I’m holding the text in one hand, and working on it with Sublime in the other. I discovered this accidentally, too – I’ve felt pretty productive with Sublime after the (tiny) initial bump, and I occasionally, gradually, get better as I learn new tricks.

I switched to Sublime after trying to learn Vim for a month or so. I’d been an emacs user for a few years, but I was under-using it, and didn’t need all the extra machinery. Vim seemed lighter, so I tried it out. But it felt like learning emacs all over again, but with different incantations: everything forced into the keyboard. And I get that! I’m a home-row Dvorak typist! But I still felt like emacs and vim were a step back from humbler tools like Programmer’s Notepad.

Bret Victor’s talk suggests an interesting explanation for that. He points out that some animations are a pain to create manually, and some behaviors are hard to code into the tool: so you divide and allocate tasks to the computer and the artist according to their abilities, and their cooperation produces the best effect.

Maybe this explains the appeal of these less-hardcore text editors. Sure, using the mouse and buttons for everything, a la Microsoft Word, is tedious, but so is forcing all interaction through the keyboard. Maybe a better allocation of tasks, a better balance of responsibilities between typist and tool, is what’s needed.

Standard
Processing, Programming

Cantor’s Snowflake

The Koch snowflake is a famous fractal.

The Koch Snowflake fractal

So is the Cantor set.

The Cantor set

Less famous, maybe, is Cantor dust, a version of the Cantor set made with squares instead of lines, which apparently earned it a much cooler name.

But as far as I know, we have no Cantor snowflake.

Since it’s Christmas, and since, in the odd quiet moments between holiday noise, Daniel Shiffman’s Nature of Code has been keeping me company, I wondered if we could make a Cantor snowflake.

Here’s what I came up with.

cantor-snowflake

As a bonus, it contains the Koch snowflake inside of it! I didn’t expect that.

I also rendered a Cantor snowflake PDF, which has a couple extra generations. It could make a nice bookmark.

Here’s the sourcecode, which is also running on openprocessing:

void setup() {
  size(1450, 300);

  background(255);
  noStroke();
  fill(0);

  cantorSnowflake(0, height/2, 140, 280);
}

void cantorSnowflake(float x, float y, float length, float sideStep) {
  if (length < 0.1) return;

  pushMatrix();

  hexagon(x, y, length);

  translate(sideStep, 0);

  for (int i = 0; i < 6; i++) {
    PVector point = vector(i * THIRD_PI, length * 2 / 3);
    cantorSnowflake(point.x, point.y, length / 3, sideStep);
  }

  popMatrix();
}

void hexagon(float centerX, float centerY, float length) {
  translate(centerX, centerY);

  beginShape();
  for (int i = 0; i < 6; i++) {
    hexPoint(vector(i * THIRD_PI, length));
  }
  endShape(CLOSE);
}

void hexPoint(PVector v) {
  vertex(v.x, v.y);
}

PVector vector(float rads, float length) {
  return new PVector(cos(rads) * length, sin(rads) * length);
}

Happy Christmas!

Standard
Processing

Symmetrical Portraits, Undone

Julian Wolkenstein’s Symmetrical Portraits project just made the rounds. I could’ve sworn I saw it on Brain Pickings, but I can’t find it now. Whatever, no matter.

It’s a weird-looking project: take a bunch of head-shots, cut them down the middle, and mirror each half, so one asymmetrical face becomes two symmetrical faces. It’s startling how much some of the pairs differ from each other. There’s a hypothesis that symmetry makes the people more attractive, but some of them are pretty uncanny:

So what’s a Processing goof-off going to do? Tear them apart, and put them back together. I don’t know whether the asymmetrical version is right, or whether it’s backwards, but I don’t think it really matters, unless you know the person in the photo. Click ‘em for big versions.












Here’s the code I used to de-symmetry them. Note the mouse controls: I had to tweak some of them, especially that second one of the blond short-haired guy.

// 36_Wolkenstein_12.jpg
String[] files = new String[] {
  "01_v2", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"
};
PImage[] origImgs;

int imgIndex = 0;

void setup() {
  PImage img = load(files[0]);
  size(ceil(img.width * 1.5), img.height);

  origImgs = new PImage[files.length];

  for (int i = 0; i < files.length; i++) {
    origImgs[i] = load(files[i]);
  }
}

void draw() {
  PImage orig = origImgs[imgIndex];
  image(orig, 0, 0);

  int placeLine = round(orig.width * 1.25);
  int cropLine = round(orig.width * 0.75);

  int placeOffset = round(map(mouseX, 0, width, -20, 20));
  int cropOffset = round(map(mouseY, 0, height, -20, 20));

  image(
    orig.get(0, 0, round(orig.width * 0.5), orig.height),
    orig.width, 0);

  image(
    orig.get(
      cropLine + cropOffset,
      0, round(orig.width * 0.25), orig.height
    ),
    placeLine + placeOffset, 0);
}

void keyPressed() {
  if (key == ENTER) {
    save("fixed_" + files[imgIndex] + ".jpg");
  }
  imgIndex = (imgIndex + 1) % files.length;
}

PImage load(String chunk) {
  return loadImage("36_Wolkenstein_" + chunk + ".jpg");
}
Standard