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
| ##################################################################### | |
| # runneur.rb : service which run (continuously) a process | |
| # 'do only one simple thing, but do it well' | |
| ##################################################################### | |
| # Usage: | |
| # .... duplicate this file : it will be the core-service.... | |
| # .... modify constantes in beginning of this script.... | |
| # .... modify stop_sub_process() at end of this script for clean stop of sub-application.. | |
| # | |
| # > ruby runneur.rb install foo ; foo==name of service, |
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
| import | |
| re, os, gtk2, gdk2, cairo, glib2, strutils, sequtils, math, typeinfo, macros | |
| let | |
| EXPOSURE_MASK = 0x000002 | |
| POINTER_MOTION_MASK = 0x000004 | |
| POINTER_MOTION_HINT_MASK = 0x000008 | |
| BUTTON_MOTION_MASK = 0x000010 | |
| BUTTON1_MOTION_MASK = 0x000020 | |
| BUTTON2_MOTION_MASK = 0x000040 |
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
| import | |
| re, os, gtk2, gdk2, glib2, strutils, sequtils, math, typeinfo, macros | |
| ###################################### Engine | |
| ############ Stack layout | |
| var | |
| gstack : seq[PBox] = @[] | |
| glastWidget : PWidget |
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
| import | |
| re, os, gtk2, gdk2, glib2, strutils, sequtils, math, typeinfo, macros | |
| ###################################### Engine | |
| ############ Stack layout | |
| var | |
| gstack : seq[PBox] = @[] | |
| glastWidget : PWidget |
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 | |
| # | |
| ########################################################## | |
| # rfilter.rb : filter on stdin, splitted on blanc(s) | |
| ########################################################## | |
| require 'time' | |
| require 'date' | |
| require 'fileutils' | |
| require 'pp' | |
| require 'json' |
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_relative 'utils' # define : chrono(comment) { code de measure } | |
| ###################### bubble sort | |
| def bsort(a) | |
| 0.upto(a.size-1) { |i| | |
| i.upto(a.size-1) {|j| a[i],a[j]=a[j],a[i] if a[j]<a[i] } | |
| } | |
| 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
| def sql | |
| fn="rdb.db" | |
| if defined?($data) | |
| ( yield( a=Marshal.load(Marshal.dump($data)) ) ; | |
| $data=a ; File.open(fn,"rb+") { |f| Marshal.dump($data,f) } | |
| ) rescue p $! | |
| return | |
| end | |
| File.exists?(fn) || File.write(fn,"") | |
| File.open(fn,"rb+") do |f| |
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
| # GClient.rb | |
| # | |
| require 'thread' | |
| require 'socket' | |
| require 'timeout' | |
| BasicSocket.do_not_reverse_lookup = true | |
| Thread.abort_on_exception = true | |
| class GClient |
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_relative 'utils' | |
| filename="x.txt" | |
| content=<<EEND | |
| =============== First line | |
| aaaaaaaaaaaa | |
| bbbbbbbbbbbb | |
| 111111111111 | |
| Aéàèû | |
| --------------- Fin |
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
| # from Rosetta code, ruby version | |
| # sudoku test finding in Groovy part | |
| # tested with ruby 2.0 1.9 JRuby mri 1.0 | |
| def read_matrix(data) | |
| matrix = [] | |
| fh=data.split("\n") | |
| (0..8).each { |i| | |
| l = fh.shift |