DEC 30
Every time you sniff and say somebody has “too much free time,” the part of you that used to love making things for pure joy dies a little.
Introducing the `—>` operator!
#include <stdio.h> int main() { int x = 10; while( x --> 0 ) // x goes to 0 { printf("%d ", x); } }
Via Stack Overflow
DEC 30
If we can’t catch a Nigerian with a powerful explosive powder in his oddly feminine-looking underpants and a syringe full of acid, a man whose own father had alerted the U.S. Embassy in Nigeria, a traveler whose ticket was paid for in cash and who didn’t check bags, whose visa renewal had been denied by the British, who had studied Arabic in Al Qaeda sanctuary Yemen, whose name was on a counterterrorism watch list, who can we catch?
DEC 27
RPCFN: Mazes came across my radar this morning, and although I’m not a Ruby newbie, I thought it might be a fun warmup for the day. And it was! My solution follows:
class Maze class Node attr_accessor :x, :y, :distance def initialize(x, y, distance=0) @x = x @y = y @distance = distance end def coords [x, y] end def neighbors [[@x-1,@y], [@x+1,@y], [@x,@y-1], [@x,@y+1]].map {|x,y| Node.new(x, y, @distance+1) } end end # assumptions: # * only one A # * only one B # maze is bounded on all four sides def initialize(maze_str) @maze = maze_str.dup @width = @maze.index("\n") + 1 # add one to account for the "\n"s a = @maze.index('A') start_coords = a.divmod(@width).reverse @start_node = Node.new(*start_coords) @end_node = nil @nodes = [ @start_node ] calculate end def calculate loop do node = @nodes.shift node.neighbors.each do |neighbor| case @maze[coords_to_index(*neighbor.coords)].chr when ' ' @maze[coords_to_index(*neighbor.coords)] = 'x' @nodes << neighbor when 'B' @end_node = neighbor return end end return if @nodes.empty? @nodes.sort_by!(&:distance) end end def solvable? !!@end_node end def steps @end_node.distance rescue 0 end def coords_to_index(x, y) y * @width + x end end
Edit: And for fun, here’s a slightly golfed version:
class Maze def initialize(s) @m = s.dup @d = r(@m.index('A'),@m.index("\n")+1) end def r(a,w) n = [[1,a]] until n.empty? do d,i = n.shift [i-w,i+w,i-1,i+1].each do |j| case @m[j] when 32 @m[j] = 'x' n << [d+1,j] when 66 return d end end n.sort! end nil end def solvable?; !!@d; end def steps; @d || 0; end end
DEC 27
we’re reading on screen, we’re clicking through a document page by page. Why? Why would we want to replicate one of the worst features of print? I’m concerned that the word “book” in “ebook” implicitly limits where we think we can go.
One of the oddest comments on Inverting the Pyramid came from a US reviewer who expressed surprise that 140 years of tactical history seemed to have produced nothing more sophisticated than moving a player a little bit forward or back, and speculated on the impact an American football offensive or defensive coach might have on football. I would suggest that the anarchic nature of football, the lack of set-plays to be replicated and practised, militates against the sort complex pre-rehearsed moves he was talking about.
I find this especially interesting, since ultimate strategy falls in between soccer and football. Ultimate is broken up into individual points, allowing for more more football-esque tactics, but within each point, there’s room for improvisation like in soccer.
DEC 26
Seriously, what’s it going to take to get people to stop misusing the word “believe”? If you think homosexuality is a sin, then you think that it exists, and therefore you absolutely believe in it. I’m usually sanguine on the way that words shift meanings, but in this case, I have to protest. People are using the word “believe” instead of the more accurate words “approve” or even “accept”, because they want cover for their bigotry. They hope the word “believe” puts their bigotry into the Religion Zone, therefore above criticism. Well, I say fuck that. If you’re going to be a bigot, fucking own it.
DEC 16
This “R2” moniker has gained favor in Redmond in the last few years as a way of saying, “It’s the same software, honest! We’ve nailed on some bits to the side.” It’s supposed to appeal to IT departments that are allergic to disruptive changes.
It goes both ways; versioning and product descriptions are definitely influenced by marketing depending on what’s wanted. A big update seems a lot safer when served as an incremental bump in the product, and a small update can look more impressive by revving the actual version number.
Cosell: “I don’t care that the program works. The fact that you’re working here at all means that I expect you to be able to write programs that work. Writing programs that work is a skilled craft and you’re good at it. Now, you have to learn how to program.”
Just because a program works doesn’t mean that it’s acceptable code.
