This file contains hidden or 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 nz = $('p,h1,h2,h3,h4,h5,h6').filter(":contains('New Zealand')"); | |
| nz.each(function(){ | |
| $(this).html( $(this).html().replace("New Zealand", "New Zealand")); | |
| }); |
This file contains hidden or 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 logger = function(e){ | |
| if(console){ | |
| console.log(e); | |
| } else{ | |
| alert(e); | |
| } | |
| } |
This file contains hidden or 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 Tree | |
| attr_accessor :children, :node_name | |
| def initialize(node_name, strucutre={}) | |
| @node_name = node_name | |
| @children = [] | |
| strucutre.each_pair do |k,v| | |
| @children.push(Tree.new(k,v)) | |
| end | |
| end |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| q = ARGV[0] | |
| File.open('search.txt', 'r') do |infile| | |
| i = 0 | |
| while(line = infile.gets) | |
| i = i + 1 | |
| puts "#{i}: #{line}" if line.index(q) != nil | |
| end |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| a = (1..16).to_a | |
| # without each_slice | |
| a.each do |i| | |
| puts i.to_s | |
| if i % 4 == 0 then | |
| puts ',' | |
| end |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] | |
| a.each do |i| | |
| puts i.to_s | |
| if i % 4 == 0 then | |
| puts ',' | |
| end | |
| end |
This file contains hidden or 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
| h.each_pair do |k,v| | |
| puts k | |
| puts v | |
| end |
This file contains hidden or 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
| a = ['abc', 'def', 'ghi'] | |
| h = {} | |
| a.each {|i| h[a.index(i).to_s => i} |
This file contains hidden or 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
| "Hello Ruby".index("Ruby") |
This file contains hidden or 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
| puts "Hello, world" |
NewerOlder