No Apps, No Servers
Only You
Your Browser
And an idea worth sharing
| require 'benchmark' | |
| class Object | |
| def deep_clone1() Marshal.load(Marshal.dump(self)) end | |
| def deep_clone2() self.clone end | |
| def deep_clone3() eval(self.inspect) end | |
| def ewb(o) self.each_with_object(o) { |k,oo| yield(k,oo) } end | |
| end | |
| class Numeric | |
| def deep_clone2() self+0 end |
| ################################################################################ | |
| # utils.rb | |
| ################################################################################ | |
| # | |
| # ssh : ssh_exec(...) | |
| # scp : scp_get_file(...) | |
| # scp_get_dir(...) | |
| # scp_put_file(...) | |
| # scp_get_dir(...) | |
| # |
| require 'open-uri' | |
| require 'nokogiri' | |
| def getCount(name) | |
| url="https://rubygems.org/gems/#{name}" | |
| Nokogiri::HTML(open(url)).css("span.gem__downloads").last.content.gsub(/[\D]+/,'').to_i | |
| end | |
| framework="Ruiby" |
| w=%w{acquittement acquittements acquittent acquitter acquittera acquitterai acquitteraient acquitterais acquitterait acquitteras acquitterent acquitterez acquitteriez acquitterions acquitterons acquitteront acquittes acquittez acquittiez acquittions acquittons } | |
| w=%w{romane romanus romulus rubens ruber rubuicon rubicundus} | |
| class String | |
| def common(other) | |
| return('') if size==0 || other.size==0 | |
| scan(/./).zip(other.scan(/./)).to_a.each_with_object([]) {|(a,b),l| if a==b then l<<a else break(l) end }.join("") | |
| end | |
| end | |
| # find 101 with [2, 4, 5, 7, 10, 50] : | |
| # 4 add 50 => 54 | 54 mult 2 => 108 | 108 moin 7 => 101 | |
| $op=%i{div mult add moin} | |
| # elementary calculation, with "Le compte est bon" specific rules | |
| def calc(n1,op,n2) | |
| case op | |
| when :add then n1+n2 | |
| when :moin |
| ############################################################## | |
| # bourse.rb | |
| ############################################################## | |
| require 'json' | |
| require 'httpclient' | |
| require 'yahoo-finance' | |
| unless Dir.exists?("dsl-gtk") | |
| require 'Ruiby' | |
| else | |
| require_relative 'dsl-gtk/lib/Ruiby.rb' |
| ################################ Crystall scripts | |
| def chrono(text) | |
| s=Time.now | |
| yield | |
| e=Time.now | |
| d=(e.to_f-s.to_f)*1000 | |
| if d>1 | |
| puts "#{text} : #{d} ms" | |
| else |
| def chrono(text=nil,div=1) | |
| date_start=Time.now.to_f | |
| yield | |
| date_end=Time.now.to_f | |
| duree= (date_end - date_start)*1000 | |
| duree/=div if div>1 | |
| sduree= case duree | |
| when 0..1 then (duree*1000).to_s + " micro s." | |
| when 1..3000 then duree.to_s + " ms" | |
| when 3000..10000 then (duree/1000).to_s + " sec" |
| ################################ Crystal scripts | |
| def chrono(text) | |
| s=Time.now | |
| yield | |
| e=Time.now | |
| d=(e.to_f-s.to_f)*1000 | |
| if d>1 | |
| puts "#{text} : #{d} ms" | |
| else |