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
function check_me(obj){ | |
alert(obj.innerHTML); | |
} |
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/ruby | |
opts = [] | |
args = [] | |
ARGV.each do |a| | |
if a =~ /^(-[a-zA-Z]+)/ | |
opts << a | |
else | |
args << a | |
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
function strToAni(str) { | |
var regX = /(^[2-9]\d{0,2})\-?(\d{0,3})\-?(\d{0,4})$/; | |
var matches = regX.exec(str); | |
fstr = matches[1]; | |
if (matches[2]){ | |
fstr += "-" + matches[2]; | |
} | |
if (matches[3]){ | |
fstr += "-" + matches[3]; | |
} |
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
def receive_images_contr_method | |
image_path = "tmp/my_img#{params[:id_my_img]}.jpg" | |
content_length = request.content_length | |
my_read = request.body.read(content_length) | |
my_base64 = Base64.decode64(my_read) | |
image = open(image_path, "w") | |
image.write(my_base64) | |
image.close | |
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
hsh = {}; (0..rand(5)).each { |idx| hsh["val#{idx}"] = [rand(5),rand(5),(idx % 2 == 0) ? hsh.clone: rand(5)] * (rand(2)+1) }; hsh | |
my_taco = TacoHash.new | |
my_taco.write_attributes(hsh) | |
my_taco.save | |
my_new_taco = TacoHash.last | |
#<TacoHash _id: 4e6a5a031a2c840d83000002, val0: [2, 0, {}, 2, 0, {}], val1: [2, 1, 2], val2: [1, 4, {"val0"=>[2, 0, {}, 2, 0, {}], "val1"=>[2, 1, 2]}], val3: [1, 1, 1, 1, 1, 1], val4: [4, 2, {"val0"=>[2, 0, {}, 2, 0, {}], "val1"=>[2, 1, 2], "val2"=>[1, 4, {"val0"=>[2, 0, {}, 2, 0, {}], "val1"=>[2, 1, 2]}], "val3"=>[1, 1, 1, 1, 1, 1]}, 4, 2, {"val0"=>[2, 0, {}, 2, 0, {}], "val1"=>[2, 1, 2], "val2"=>[1, 4, {"val0"=>[2, 0, {}, 2, 0, {}], "val1"=>[2, 1, 2]}], "val3"=>[1, 1, 1, 1, 1, 1]}]> | |
my_new_taco.val0 |
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
require 'uri' | |
require 'net/http' | |
require 'net/https' | |
opts = ARGV.collect{|a| a if a =~ /^(-[a-zA-Z]+)/}.compact | |
url = ARGV - opts | |
use_https = lambda{|http| http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE} | |
requester = lambda{|http, uri| http.request(Net::HTTP::Get.new(uri.request_uri))} | |
if url.size > 1 | |
puts "Multiple Urls not Supported" |
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
require 'mongoid' | |
# MongoDB ENV vars | |
File.open(File.join(RAILS_ROOT, 'config/mongodb.yml'), 'r') do |f| | |
@settings = YAML.load(f)[RAILS_ENV] | |
end | |
port = @settings["port"].nil? ? Mongo::Connection::DEFAULT_PORT : @settings["port"] | |
host_arr = @settings["host"] | |
connect = Mongo::Connection.multi([[host_arr[0], 27017], [host_arr[1], 27017], [host_arr[2], 27017]], :read_secondary => true) | |
db = connect.db(@settings["database"]) |
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/local/bin/ruby | |
require 'stringio' | |
require 'rubygems' | |
require 'icanhasaudio' | |
reader = ::Audio::MPEG::Decoder.new | |
str_io = StringIO.new | |
input = File.open(ARGV[0], "rb") | |
plot_points = [] | |
buf = reader.send(:skip_id3_header, input) |
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
(1..100).each do |x| | |
case | |
when 0 == ((x%3)+(x%5)) | |
puts "fizz buzz" | |
when 0 == (x%3) | |
puts "fizz" | |
when 0 == (x%5) | |
puts "buzz" | |
else | |
puts x |
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
def swap(a,b) | |
a = a + b | |
b = a - b | |
a = a - b | |
return {:a => a, :b => b} | |
end |
OlderNewer