Skip to content

Instantly share code, notes, and snippets.

while(s=gets)
a = s.split(' ')
puts IO.foreach('input.txt'){|line|
array = line.split(' ');
# 下面的判断若通过,则a的成员都在array中,可以直接返回
break array[0] if( (array - a).size == array.size - a.size)
}
end
@fsword
fsword / fiber.rb
Last active October 1, 2015 18:18
fiber recursion
def f(i); puts('%10s' % i) if i%1000==0; Fiber.new{f(i+1)}.resume end; f(0)
@fsword
fsword / fiber_transfer.rb
Created March 13, 2012 12:39
fiber transfer 例子
require 'fiber'
x = nil
f1 = nil
f1 = Fiber.new do |f|
1000.times do
p 'f1'
sleep 0.1
@fsword
fsword / use_fail_dmesg.out
Created October 15, 2011 13:35
usb connect failed
[ 3420.375053] sd 7:0:0:0: [sdb] Attached SCSI removable disk
[ 3451.160068] usb 1-8: reset high speed USB device using ehci_hcd and address 11
[ 3482.200129] usb 1-8: reset high speed USB device using ehci_hcd and address 11
[ 3513.160142] usb 1-8: reset high speed USB device using ehci_hcd and address 11
[ 3544.200062] usb 1-8: reset high speed USB device using ehci_hcd and address 11
[ 3575.160058] usb 1-8: reset high speed USB device using ehci_hcd and address 11
[ 3600.550125] INFO: task udisks-daemon:1957 blocked for more than 120 seconds.
[ 3600.550130] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 3600.550133] udisks-daemon D 0000000000000001 0 1957 1956 0x00000000
[ 3600.550138] ffff8800b30b7958 0000000000000082 ffff8800b30b7fd8 ffff8800b30b6000
@fsword
fsword / catalina.out
Created August 31, 2011 11:54
rails application on tomcat throw exception
Aug 31, 2011 7:30:17 PM org.apache.catalina.startup.Embedded initDirs
SEVERE: Cannot find specified temporary folder at /home/lifu/projects/apache-tomcat-6.0.32/temp
Aug 31, 2011 7:30:17 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /home/a/project/java/jre/lib/amd64/server:/home/a/project/java/jre/lib/amd64:/home/a/project/java/jre/../lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib
Aug 31, 2011 7:30:18 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-9999
Aug 31, 2011 7:30:18 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 747 ms
Aug 31, 2011 7:30:18 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina