array_with_blank_strings.compact.reject(&:blank?) >> array_with_blank_strings = ["Item 1", "Item 2", " ", "Item 3", nil] ...
def browser?(b)
user_agents = {
:ff => /Firefox/,
...
Ruby browser detection and url r...
i have a simple browser det...
def translation_links
lang = [
%w[en english us],
...
Ruby nested array to set of html...
i have a simple array that ...
FIELDS = [ 'first', 'last', 'band' ]
DATA = [['Kurt', 'Cobain', 'Nirvana'],
['Jimi', 'Page', 'Led Zeppelin'],
...
Ruby Map fields array and data a...
First posting here. I just ...
public static int[] zigzagify(int[] array, int xmax, int ymax) {
int[] zz = new int[array.length]; //zigzag array
if (array.length != xmax * ymax) {
...
Java Zig Zag ordering of array
This is the code that is su...
artists = [1, 2, 3]
column_1 = artists[0..artists.size/2]
column_2 = artists[artists.size/2+1..artists.size]
Ruby Split an array into half
The example works if the ar...
times.each do |time|
events.each do |event|
if time.strftime("%I:%M %p") == event.datetime.strftime("%I:%M %p")
...
Ruby two for loops cleanup?
times is an array of dateti...
module Enumerable
def cluster
sort.inject([[]]) do |out, n|
...
Ruby Enumerable#cluster
%w[app noot app mies zoo m...
xml = REXML::Document.new(data) artists = [] ...
Ruby cleaner way to limit result...
by timmyvontrimble.myopenid.com,
July 14, 2008 19:12,
10 refactorings, tagged with rails, ruby, xml, array, iteration
Wow! All of these refactori...
<?php /* * This is a test of a rules based iterative algorithm... ...
PHP Rules Based Iterator
by James Stansfield,
June 15, 2008 13:52,
1 refactoring, tagged with php, iterate, loop, array, rules
I had need for an iterative...
def find_npa(dialed_nxx) nxx_819 = [ 205, 208, 210, 213, 243 ] ...
Ruby Array iteration
I'm new to Ruby, so give me...
This code will firstly remo...