This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Ruby assignment option to assign unless nil | |
replacement_content = page_contents.content_label_find(item) | |
element.inner_html = replacement_content if replacement_content | |
# or | |
if pc = page_contents.content_label_find(item) | |
element.inner_html = pc | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
helpers do | |
def cycle | |
%w{even odd}[@_cycle = ((@_cycle || -1) + 1) % 2] | |
end | |
CYCLE = %w{even odd} | |
def cycle_fully_sick | |
CYCLE[@_cycle = ((@_cycle || -1) + 1) % 2] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var table = $('<table>').attr('id', 'host-' + host.host) | |
$('<thead>') | |
.append('<tr><th class="name">File name</th><th class="size">Size</th></tr>') | |
.appendTo(table); | |
table.append('<tfoot>') | |
.append('<tbody>') | |
.appendTo('#wrap') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
attr_accessor :some_attr | |
def initialize(val) | |
self.some_attr = val | |
end | |
def ==(other) | |
self.some_attr == other.some_attr | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static VALUE | |
rb_ary_uniq_bang(ary) | |
VALUE ary; | |
{ | |
VALUE hash, v, vv; | |
long i, j; | |
hash = ary_make_hash(ary, 0); | |
if (RARRAY(ary)->len == RHASH(hash)->tbl->num_entries) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Date | |
def to_words | |
today = Date.today | |
case self | |
when today | |
"Today" | |
when today - 1 | |
"Yesterday" | |
when today + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../spec_helper' | |
require File.dirname(__FILE__) + '/../../app/models/notifications' | |
class Notifications | |
def self.spec_new(method_name,*parameters) | |
n = self.allocate | |
n.__send__ :initialize_defaults, method_name | |
yield(n) if block_given? | |
n.__send__(method_name, *parameters) | |
return n |
NewerOlder