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
My plea to you today is to start a side project. Scratch your own itch. Be creative. Share something with the world, or keep it to yourself.
Long. Some choice wisdoms though.
Apply this patch to your git src before you compile:
cd $GIT_SRC
curl http://gist.github.com/raw/6442/37801bd3ec887329ba9e01119e7f568cc620c533 | patch -p1
"".nil?
# => false
Consequently:
foo = ""
if foo
# THIS WILL EXECUTE!
end
Please be careful. Use String#empty or Object#blank?
Dr. Nic in My attempt at sake task management
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.
in application.rb:
def html_escape(*args)
ERB::Util.html_escape(*args)
end
alias :h :html_escape
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!
Dan Cederholm taking Robert Bringhurst to heart: Use CSS to make a list of common, and beautiful, italic ampersands and substitute them in Roman text. Why didn’t I think of this before‽ (via SimpleBits)
Been doing this for a while, ever since topfunky wrote about it.
(via jhongosh)
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.
The idea being here that you trust the 2.x series, but not the 3.x series. Cool!
Okay, so if you haven’t checked this out yet, let me summarize: everything is bigger. That’s all.
Oh, there is as new color them. But I can’t even tell if I like it because every element on the page is so freaking massive.
(via peterwknox)
Gruber on the MobileMe Reorg