git svn dcommit with username on 1.6.0

Apply this patch to your git src before you compile:


cd $GIT_SRC
curl http://gist.github.com/raw/6442/37801bd3ec887329ba9e01119e7f568cc620c533 | patch -p1

"".nil?


"".nil?
# => false

Consequently:


foo = ""
if foo
  # THIS WILL EXECUTE!
end

Please be careful. Use String#empty or Object#blank?

“ Now take a moment to reflect on just how empty your repository is. A fine moment in open-source where you’ve essentially cloned an empty repository. Hardly worth the effort, but since Chris is a creator of github then if he creates an empty repository then who am I to disagree. Empty it shall start. ”

Dr. Nic in My attempt at sake task management

Uh oh.

Uh oh.

nycmeetups:


This Thursday. SHAKE SHACK. 7 p.m. Reblog + be there.
Get your game face on, carnivores.
Beers near the park to follow.


I’ll be there.

nycmeetups:

This Thursday. SHAKE SHACK. 7 p.m. Reblog + be there.

Get your game face on, carnivores.

Beers near the park to follow.

I’ll be there.

html_escape in your flashes

in application.rb:


def html_escape(*args)
  ERB::Util.html_escape(*args)
end
alias :h :html_escape

Redesign in Progress

UPDATE: Bedtime for tonight. Not done yet.

Random Subset

How would you implement grabbing a random n-sized subset of an array? ie,


class Array
  def rand_subset(n)
    # WRITE ME
  end
end

My initial thought was self.sort_by{rand}.slice(0,n). Although this runs in something around O(n*log(n)), it just seems like there has to be a better way.

Ron introduced this into a project at work:


class Array
  def rand_subset(n)
    subset = []
    n = [n.to_i, self.size].min
    
    until subset.size == n
      x = self.rand; subset << x unless subset.include?(x) # Avoid duplicates
    end
    
    subset
  end
end

Here’s my attempt:


class Array
  def rand_subset(n)
    n = [n, self.size].min
    queue = self.dup
    (1..n).inject([]) do |subset, i|
      subset << queue.delete_at(rand(queue.length))
    end
  end
end

I’m not sure how Ruby goes about implementing Arrays (probably as a linked list of some sort), so it would take some figuring how both of these compare in terms of speed and memory usage.

Have a better way to write rand_subset? I want to hear about it!

~>


  gem 'will-paginate', '~>2.2'
Notice that we only include 2 digits of the version. The operator will drop the final digit of a version, then increment the remaining final digit to get the upper limit version number.

RubyGems User Guide

The idea being here that you trust the 2.x series, but not the 3.x series. Cool!

“ The antiscience agenda is visible as early as kindergarten, with its infantile versions of the diversity agenda and its early budding of self-esteem lessons. But it complicates and propagates all the way up through grade school and high school. In college it often drops the mask of diffuse benevolence and hardens into a fascination with “identity. ”

How Our Culture Keeps Students Out of Science

“ The clusterfuck that has been the first month of MobileMe […] has resulted in the inevitable: a reorg. “Reorg” being Apple-speak for “this shit had better change”. ”

Gruber on the MobileMe Reorg