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
| here the diff betwen original data read from file and the data sended by | |
| web browser when save the textarea content (send by jquery, | |
| in application/x-www-form-urlencoded) form : | |
| >diff webserver.rb webserver.rb1 | |
| 145c145 | |
| < when String then (a !~ /"/) && '"'+a+'"' || "'"+a.gsub(/'/,'\\'+"'")+"'" | |
| --- | |
| > when String then (a !~ /"/) && '"'+a+'"' || "'"+a.gsub(/'/,'\'+"'")+"'" | |
| 496c496 |
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 RegisDuck | |
| include Robot | |
| def startup | |
| @last_hit=0 | |
| @sens=1 | |
| turn_radar 1 | |
| turn_gun 0 | |
| @v=3 | |
| @mt=0 |
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 'Ruiby' | |
| Ruiby.app width: 400, height: 300, title: "Game of Life" do | |
| def freemap() [[false]*MAXL]*MAXC end | |
| MAXC=MAXL=100 | |
| PASX=default_width/MAXC | |
| PASY=(default_width)/MAXL | |
| @mat=freemap() | |
| @run=false | |
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
| Ruiby.app width: 600,height: 400 do | |
| video_url="file:///#{ARGV[0] || "d:/usr/XT.avi"}" | |
| stack do | |
| @v=video(video_url,600,400-40) {|progress| @prog && @prog.progress=progress*100 } | |
| flowi { | |
| buttoni(" Start ") { @v.play } | |
| buttoni(" Stop ") { @v.stop } | |
| @prog=slider(0,0,100.0) { |pos| @v.progress= pos/100.0} | |
| buttoni(" Exit ") { exit!(0) } | |
| } |
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 'sinatra' | |
| require 'sinatra' | |
| require 'sinatra-websocket' | |
| set :server, 'thin' | |
| set :sockets, [] | |
| get '/' do | |
| if !request.websocket? | |
| erb :index |
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
| # Show dependencies of current ruby config | |
| require 'tsort' | |
| def prequire(n) | |
| puts "require #{n} ..." | |
| begin | |
| require n.to_s | |
| rescue Exception => e | |
| puts " Error : #{e}" | |
| 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
| require 'sourcify'# AST from ruby byte code | |
| require 'ripper' # AST from string code | |
| require 'pp' | |
| def ripp(code) | |
| puts "-"*70 | |
| puts code | |
| puts "- "*35 | |
| pp Ripper.sexp(code) | |
| 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
| var PDFDocument = require('pdfkit'); | |
| var ML=2000 | |
| var MC=200 | |
| var px=6000/ML | |
| var py=4000/MC | |
| doc = new PDFDocument({margin: 10,size: [6000,4000]}); | |
| for (var col=0;col<ML*px;col+=px) | |
| for (var li=0;li<MC*py;li+=py) | |
| doc.image('test.png', col,li,{fit:[px,py]}); | |
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
| /* put this file in | |
| * | |
| D:\usr\Ruby\ruby19\lib\ruby\gems\1.9.1\gems\gdk3-1.2.0-x86-mingw32\vendor\local\... | |
| * ...share\themes\GreyBird\gtk-3.0\gtk.css | |
| * | |
| * update the file : | |
| * | |
| ruby19\lib\ruby\gems\1.9.1\gems\gdk3-1.2.0-x86-mingw32\vendor\local\etc\... | |
| * ..gtk-3.0\settings.ini | |
| * with : |
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 'benchmark' | |
| REP = 10 | |
| puts 'Generating data...' | |
| class Array | |
| def qsort | |
| return self if length <= 1 | |
| pivot = self[0] | |
| less, greatereq = self[1..-1].partition { |x| x < pivot } | |
| less.qsort +[pivot] + greatereq.qsort |