Infinite Monkey Theorem

They say if you calculate pi to binary, you’ll eventually reproduce every book, song, movie, (and so on…) that ever existed. Randomness, though chaotic, can create systems as indiscriminately as it produces garbage. That’s the idea anyways. As impractical (and slow) as it would be to calculate pi to binary, it’s no surprise that over billions of years, random particles bumping into each other resulted in us chimps.

0 notes

Don't Make Me Wait

A “down to earth” reminder of why people use your web application.

0 notes

Always use URI.parse for Ruby Net::HTTP

If you Google “ruby net http”, you’ll find a swath of examples for the library’s obscure syntax. In the official documentation, they sometimes use separate string inputs for url and uri (BAD). They also use a secondary syntax using Ruby’s URI class to for your url (GOOD).

Here’s an example of the two.

Both of these actually work. However when you’re using SSL, the string argument version fails, resulting in the error message: “Errno::ECONNREFUSED: Connection refused”. Just use the URI object and it will work properly.

It’s odd that the “http.use_ssl” method doesn’t make it work in both cases. But for your own safety, just always use the URI class for storing your urls.

0 notes

Why I’ll never buy another Samsung product

A while back, I bought my parents a 50” Samsung DLP television (HLT5076SX). Now it’s become overrun with little white dots, and it’s too distracting to watch anything on it (except maybe Cosmos, or anything with stars).

The problem:
Little white dots, EVERYWHERE.

Samsung response:
No coverage after a year. You’re stuck with hundreds on large dots on your screen.

UPDATE

Talked to a Samsung support supervisor (Joey #797) and explained how our tv’s screen has been slowly devoured by little white dots. He told me, in essence, that Samsung would be happy to bill us for a technician to fix the responsible faulty part(s). They don’t cover their faulty products after a year, regardless.

I tried explaining that a tv shouldn’t break after a year of regular use. Despite the same problem reported on similar models, they offer no permanent solution, as these white dots are caused by manufacturing defects across many of their television parts. When you spend nearly $1000 on a product, you expect a company to stand for at least a functional level of quality.

After all is said and done, I’ll probably put it on Craigslist “AS IS” and replace it with a cheaper, higher quality Visio LCD.

tl:dr I would never purchase or recommend buying a Samsung product again.
0 notes

Converting projects to haml

If you’re transitioning an old codebase from messy html/erb to haml, you’ll find the html2haml utility VERY handy. However, it’s a bit cumbersome if you want to do batch conversions of files.

Terrbear has a bash script solution for this:

0 notes

Such a great book. I can’t believe it’s taken me this long to start it.

Its concise (yet cautious) insights make it an essential read. However, it covers enough language basics to make it suitable for even Ruby beginners. If you’re already familiar to programming, but want to become a better software architect… you should definitely pick up a copy!

Such a great book. I can’t believe it’s taken me this long to start it.

Its concise (yet cautious) insights make it an essential read. However, it covers enough language basics to make it suitable for even Ruby beginners. If you’re already familiar to programming, but want to become a better software architect… you should definitely pick up a copy!

0 notes

CSS3 for styling select boxes (WANTED)

I’m working on a project that uses custom styled forms. Before CSS3, it was rather difficult to create select inputs that don’t look like the system default (impossible without JavaScript).

Now you can use the -webkit-appearance property to style it just like any other element. It’s simple:

select {
  -webkit-appearance: none;
  border-radius: 0px;
}

However, it appears that you still can’t style the options list that appears when clicking the select input. For example, you can’t add custom background styles to that option list.

option:hover {
  /* Doesn't work */
  background: #ababab;
}

While there are plenty of great JavaScript solutions that let you style both the input element and options (via ol, li, etc)… I’m looking for something that takes advantage of emerging web standards.

I want a webkit property that allows full-styling control of a select’s option tags!

0 notes

Haml and HTML 5 data attributes

With the mainstreaming of custom HTML attributes, it’s becoming valid (in HTML5) to use “data”-prefixed attributes to describe your content. I think it’s a great feature. It allows you to keep your markup clean from messy inline javascript and hidden fields.

If you’re coding your markup in HAML though, here’s a small bug that’s irksome.

.container
  .item{:data-content => "#{@record.content}"}= @record.content_abbreviated

This is more of a Ruby’ism than anything, since you’re not allowed to use hyphens in symbols. Given the way I’m used to writing my HAML code, it just seems like an odd exception for these custom attributes. The solution is simple enough, I suppose.

.container
  .item{"data-content" => "#{@record.content}"}= @record.content_abbreviated

UPDATE (7/16)

As Derek Perez points out, you can still use symbols; Ruby just has an odd syntax for hyphenated symbols.

:symbol
"string"
:"hypenated-symbol"

UPDATE (7/27)

Chris Eppstein also mentioned HAML does, in fact, have a special syntax for data attributes.

.container
  .item{:data => {:content => "#{@record.content}"}= @record.content_abbreviated
0 notes

Syntax Highlighting

I’ll likely be posting snippets of code very soon. Here’s a syntax highlighter, implemented in javascript, that I’ll be using from here on out.

# This class will take you to the moon
class Spaceship

  def initialize
    @rocket_fuel = rand(500)
    @unit_of_distance = "unicorn blinks"
  end
  
  def potential
    sentence = "You can travel #{@rocket_fuel/3} #{@unit_of_distance}." if @rocket_fuel
    return sentence
  end

end

More: Dr. Nic’s Syntax Highlighting for Tumblr

0 notes

 Habitat.

Habitat.

0 notes