Error
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.

switch

And the Best Nerdabolous Joke Ever Award Goes to... Switch Real Car for Life-Sized Lego Car! [Video]
Thursday, 23 June 2011 12:46
Legoland California's General Manager Peter Ronchetti has a Volvo XC60. At least until a couple days ago someone decided to use a lift fork to switch it to a life-sized, 2,934-pound Lego XC90 made of 201,076 bricks. More »


Read more: http://feeds.gawker.com/~r/gizmodo/full/~3/VhQxDR88hbY/and-the-best-nerdabolous-joke-ever-award-goes-to-switch-real-car-for-life+sized-lego-car

 
Thank You For Fixing the iPad's Side Switch, Apple [Apple]
Wednesday, 12 January 2011 17:02
We weren't happy when Apple changed the iPad's side switch from an orientation lock into a mute switch, but thanks to iOS 4.3 we can calm down: Now there's finally a setting allowing us to choose what the switch does. More »


Read more: http://feeds.gawker.com/~r/gizmodo/full/~3/MTFv4zIjipo/apple-finally-lets-you-choose-what-your-ipads-side-switch-does

 
Turn On These Lights to Remind Yourself to Save Water [Lighting]
Saturday, 02 October 2010 02:40
Everytime you switch on, remind yourself to switch off. That's the message environmental artist Tanya Clarke is sending with these Liquid Lights. Made from recycled pipes and taps, the lamps use green LEDs as the light source. More »


Read more: http://feeds.gawker.com/~r/gizmodo/full/~3/KrXx0ST5ujI/turn-on-these-lights-to-remind-yourself-to-save-water

 
Using an XML file to define options OptParseSimple
Sunday, 28 February 2010 23:22
// description of your code here


class OptParseSimple

def initialize(filename, args)
doc = Document.new(File.open('options.xml','r').read)
@options = XPath.match(doc.root, 'records/option[switch!=""]')

switches = @options.map do |option|
switch = option.text('switch')
switch[0] == '-' ? switch : nil
end

switches.compact!

# split the argument switches if grouped e.g. -ltr
args.map! do |arg|

if arg[/^\-[a-zA-Z]+$/] and switches.grep(/#{arg}/).empty? then
arg[1..-1].scan(/./).map {|x| '-' + x}
else
arg
end
end

args.flatten!

a1 = options_match(@options[0], args).flatten.each_slice(2).map {|x| x if x[0]}.compact
options_remaining = XPath.match(doc.root, 'records/option[switch=""]/name/text()')
a2 = args.zip(options_remaining).map(&:reverse)
if a2.map(&:first).all? then
@h = Hash[*(a1+a2).map{|x,y| [x.to_s.to_sym, y]}.flatten]
else
invalid_option = a2.detect {|x,y| x.nil? }.last
raise "invalid option: %s not recognised" % invalid_option
end
end

def to_h()
@h
end

private

def options_match(option, args)

switch, switch_alias = option.text('switch'), option.text('alias')
switch_pattern = switch_alias ? "(%s|%s)" % [switch, switch_alias] : switch
switch_matched, arg_index = args.each_with_index.detect {|x,j| x[/^#{switch_pattern}/]}
key, value = nil

if switch_matched then

value_pattern = option.text('value')

if value_pattern then

# check for equal sign
value = switch_matched[/\=(#{value_pattern})/,1]

# check the next arg
if value.nil? and args.length > 0 then

next_arg = args[arg_index + 1]

# check to make sure it's not the next switch
next_option = @options[1] if @options.length > 1

if next_arg != next_option then
# validate using the regex
value = next_arg[/#{value_pattern}/]

if value then
args.delete_at(arg_index + 1)
else
raise option.text('errors/records/error[last()]')
end
end

else
args.delete_at(arg_index)
end

else
args.delete_at(arg_index)
end

key = option.text('name')

elsif option.text('mandatory').downcase == 'true' then

raise option.text('errors/records/error')

end

pair = [key, value]
@options.shift
next_pair = options_match(@options[0], args) if @options.length > 0

[pair, next_pair]
end

end

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/Ny04xigk-y4/10309

 
Drop down list of code in HTML
Sunday, 28 February 2010 23:22
// Using an XML file to define options OptParseSimple


class OptParseSimple

def initialize(filename, args)
doc = Document.new(File.open('options.xml','r').read)
@options = XPath.match(doc.root, 'records/option[switch!=""]')

switches = @options.map do |option|
switch = option.text('switch')
switch[0] == '-' ? switch : nil
end

switches.compact!

# split the argument switches if grouped e.g. -ltr
args.map! do |arg|

if arg[/^\-[a-zA-Z]+$/] and switches.grep(/#{arg}/).empty? then
arg[1..-1].scan(/./).map {|x| '-' + x}
else
arg
end
end

args.flatten!

a1 = options_match(@options[0], args).flatten.each_slice(2).map {|x| x if x[0]}.compact
options_remaining = XPath.match(doc.root, 'records/option[switch=""]/name/text()')
a2 = args.zip(options_remaining).map(&:reverse)
if a2.map(&:first).all? then
@h = Hash[*(a1+a2).map{|x,y| [x.to_s.to_sym, y]}.flatten]
else
invalid_option = a2.detect {|x,y| x.nil? }.last
raise "invalid option: %s not recognised" % invalid_option
end
end

def to_h()
@h
end

private

def options_match(option, args)

switch, switch_alias = option.text('switch'), option.text('alias')
switch_pattern = switch_alias ? "(%s|%s)" % [switch, switch_alias] : switch
switch_matched, arg_index = args.each_with_index.detect {|x,j| x[/^#{switch_pattern}/]}
key, value = nil

if switch_matched then

value_pattern = option.text('value')

if value_pattern then

# check for equal sign
value = switch_matched[/\=(#{value_pattern})/,1]

# check the next arg
if value.nil? and args.length > 0 then

next_arg = args[arg_index + 1]

# check to make sure it's not the next switch
next_option = @options[1] if @options.length > 1

if next_arg != next_option then
# validate using the regex
value = next_arg[/#{value_pattern}/]

if value then
args.delete_at(arg_index + 1)
else
raise option.text('errors/records/error[last()]')
end
end

else
args.delete_at(arg_index)
end

else
args.delete_at(arg_index)
end

key = option.text('name')

elsif option.text('mandatory').downcase == 'true' then

raise option.text('errors/records/error')

end

pair = [key, value]
@options.shift
next_pair = options_match(@options[0], args) if @options.length > 0

[pair, next_pair]
end

end

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/K1bfpz2icX8/10307

 


Taxonomy by Zaragoza Online