Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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)
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 / gist:2885903
Created June 7, 2012 01:16 — forked from feng92f/gist:2849163
google收录的敏感词
@fsword
fsword / prime.rb
Created June 8, 2012 16:51
求N以内的素数
def prime n
list = (2..n).to_a
(2...(n ** (0.5)).floor).each do |i|
list.delete_if{|e| e > i && e % i == 0}
end
list
end
@fsword
fsword / prime_benchmark.rb
Created June 9, 2012 04:28
prime benchmark
require './prime.rb' # user defined function
require 'benchmark'
require 'digest/md5'
result = {
4 => 'ae5161e4645f5cd58897d32f529f3ad5',
5 => 'cf7b5007830f057a04d2b696527952e7',
6 => 'a43beaed59a26b8d85868eaa8fa2e972',
7 => 'c1aa9bda24aa8bc5473ca1f51c9fd106'
}
@fsword
fsword / prime_concurrent.rb
Created June 10, 2012 11:49
prime_concurrent.rb
require 'thread'
def prime n, concurrent_num=4
full_list = (2..n).to_a
prime_list = []
stop_index = (n ** 0.5).floor
last_prime = 2
while(last_prime < stop_index)
module MyTool
module Tree
class << self
def loop root, &block
return false unless File.exist? root
block_given? ? exec(root, &block) : collect(root)
end
def exec root, &block