files=["stokesCR025.txt",\
"stokesCR05.txt",\
"stokesCR10.txt",\
"stokesCR15.txt",\
"stokesCR20.txt",\
"stokesCR25.txt",\
"stokesCR30.txt",\
"stokesCR35.txt",\
"stokesCR40.txt",\
"stokesCR45.txt",\
"stokesCR50.txt"]
rough=[0.025, 0.050, 0.100, 0.150, 0.200, 0.250, 0.300,0.350,0.400,0.450,0.500]
num=files.size
fout=File.new("curve.txt", "w")
for j in 0..num-1
fname=files[j]
puts "fname "+fname
roughness=rough[j]
file = File.new(fname, "r")
i=0
while i<2 do
line = file.gets
i=i+1
end
value1=line.match(/^[0-9]* /)
puts value1.to_s
value2=line.match(/ [-,.,0-9]*$/)
puts value2.to_s
file.close
fout.puts roughness.to_s+" "+value2.to_s
end
fout.close
Wednesday, December 16, 2009
[Work] Ruby, organize text file
Wednesday, December 2, 2009
[Ruby] make thumbnails
require "FileUtils"
require "ftools"
filetype = ".jpg"
path_in = Dir.pwd
path_out=path_in+"/thumbnail"
if !FileTest::directory?(path_out)
Dir::mkdir(path_out)
end
dir=Dir.open(path_in)
a=Array.new(dir.collect.length)
num=0
dir.each do |file|
if(file.length>filetype.length)
if (file[file.length-4..file.length]==filetype)
a[num]=file
num=num+1
end
end
end
puts num
for i in 0..num-1
fold = path_in + "/" + a[i]
fnew_ppm = path_out + "/" + a[i][0..a[i].length-5]+".ppm"
fnew_jpg = path_out + "/" + a[i][0..a[i].length-5]+".jpg"
cmdline="convert -resize 200x -quality 100 "+fold+" "+fnew_ppm
puts cmdline
system("#{cmdline}")
cmdline="convert -quality 100 "+fnew_ppm+" "+fnew_jpg
puts cmdline
system("#{cmdline}")
puts "---------------------"
File.delete(fnew_ppm)
end
[Ruby] resize image (portrait or landscape)
require "FileUtils"
require "ftools"
filetype = ".jpg"
path_in = Dir.pwd
path_out=path_in+"/size2900"
if !FileTest::directory?(path_out)
Dir::mkdir(path_out)
end
dir=Dir.open(path_in)
a=Array.new(dir.collect.length)
num=0
dir.each do |file|
if(file.length>filetype.length)
if (file[file.length-4..file.length]==filetype)
a[num]=file
num=num+1
end
end
end
puts num
for i in 0..num-1
fold = path_in + "/" + a[i]
fnew_ppm = path_out + "/" + a[i][0..a[i].length-5]+".ppm"
fnew_jpg = path_out + "/" + a[i][0..a[i].length-5]+".jpg"
#check the image size, portrait or landscape
cmdline="identify "+fold+" >t.txt"
system("#{cmdline}")
file = File.new("t.txt", "r")
line = file.gets
m=line.match(/[0-9]*x[0-9]*/)
width=m.to_s.match(/^[0-9]*/)
height=m.to_s.match(/[0-9]*$/)
#resize to ppm
if(width.to_s.to_i>height.to_s.to_i)
puts "landscape"
cmdline="convert -resize 2900x -quality 100 "+fold+" "+fnew_ppm
puts cmdline
system("#{cmdline}")
else
puts "portrait"
cmdline="convert -resize x2900 -quality 100 "+fold+" "+fnew_ppm
puts cmdline
system("#{cmdline}")
end
file.close
#convert ppm to jpg
cmdline="convert -quality 100 "+fnew_ppm+" "+fnew_jpg
puts cmdline
system("#{cmdline}")
puts "---------------------"
#delete ppm
File.delete(fnew_ppm)
end
File.delete("t.txt")
[Ruby] file rename
filetype = ".jpg"
path = "."
prefix="slide_"
dir=Dir.open(path)
a=Array.new(dir.collect.length)
num=0
dir.each do |file|
if(file.length>filetype.length)
if (file[file.length-4..file.length]==filetype)
a[num]=file
num=num+1
end
end
end
puts num
count=0
for i in 0..num-1
fnew=prefix+"%05d"%count+a[i][a[i].length-4..a[i].length]
count=count+1
old_file = path + "/" + a[i]
new_file = path + "/" + fnew
puts "old "+old_file
puts "new "+new_file
puts "--------------"
File.rename(old_file, new_file)
end
[Ruby] is a number
def is_a_number(s)
s.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
end
Thursday, October 8, 2009
[Work] Gears
http://www.premier-gear.com/worm_gears.htm
http://www.pslofamerica.com/worm-drives.htm
NEXEN ANNOUNCES ROLLER PINION GEAR SYSTEM
http://www.nexengroup.com/nexen/index.jsp
ring gear
http://www.plasticmachiningcompany.com/index.php?vid=20091009135215-39p
Align Trex 500 Main Drive Gear 162T (2 pcs) H50018-1
Main Drive Gear/164T HN7019-1
0412-259
Sceadu G Second Gear 80T (DTDS)
$29.99
0412-113
SD Main Gear 87T
$8.09
Tail Shaft With Pulley
http://www.pslofamerica.com/worm-drives.htm
NEXEN ANNOUNCES ROLLER PINION GEAR SYSTEM
http://www.nexengroup.com/nexen/index.jsp
ring gear
http://www.plasticmachiningcompany.com/index.php?vid=20091009135215-39p
Align Trex 500 Main Drive Gear 162T (2 pcs) H50018-1
Main Drive Gear/164T HN7019-1
0412-259
Sceadu G Second Gear 80T (DTDS)
$29.99
0412-113
SD Main Gear 87T
$8.09
Tail Shaft With Pulley
Monday, October 5, 2009
[Work] Visual Studio Linker tools errors
Linker Tools Warning LNK4098
defaultlib "library" conflicts with use of other libs; use /NODEFAULTLIB:library
You are trying to link with incompatible libraries.
Important The run-time libraries now contain directives to prevent mixing different types. You’ll receive this warning if you try to use different types or debug and non-debug versions of the run-time library in the same program. For example, if you compiled one file to use one kind of run-time library and another file to use another kind (for example, single-threaded versus multithreaded) and tried to link them, you’ll get this warning. You should compile all source files to use the same run-time library. See the Use Run-Time Library (MD, /ML, /MT, /LD) compiler options for more information.
You can use the linker’s /VERBOSE:LIB switch to determine which libraries the linker is searching. If you receive LNK4098 and want to create an executable file that uses, for example, the single-threaded, non-debug run-time libraries, use the /VERBOSE:LIB option to find out which libraries the linker is searching. The linker should print LIBC.LIB and not LIBCMT.LIB, MSVCRT.LIB, LIBCD.LIB, LIBCMTD.LIB, or MSVCRTD.LIB as the libraries searched. You can tell the linker to ignore the the incorrect run-time libraries by typing the incorrect libraries in the Ignore Libraries text box on the Link tab of the Settings dialog box in Developer’s Studio or by using the /NODEFAULTLIB:library option with LINK for each library you want to ignore. See the Ignore Libraries (/NODEFAULTLIB) linker option for more information.
The table below shows which libraries should be ignored depending on which run-time library you want to use.
To use this run-time library Ignore these libraries
Single-threaded (libc.lib) libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
Multithreaded (libcmt.lib) libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
Multithreaded using DLL (msvcrt.lib) libc.lib, libcmt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
Debug Single-threaded (libcd.lib) libc.lib, libcmt.lib, msvcrt.lib, libcmtd.lib, msvcrtd.lib
Debug Multithreaded (libcmtd.lib) libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, msvcrtd.lib
Debug Multithreaded using DLL (msvcrtd.lib) libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib
For example, if you received this warning and you want to create an executable file that uses the non-debug, single-threaded version of the run-time libraries, you could use the following options with the linker:
/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib
defaultlib "library" conflicts with use of other libs; use /NODEFAULTLIB:library
You are trying to link with incompatible libraries.
Important The run-time libraries now contain directives to prevent mixing different types. You’ll receive this warning if you try to use different types or debug and non-debug versions of the run-time library in the same program. For example, if you compiled one file to use one kind of run-time library and another file to use another kind (for example, single-threaded versus multithreaded) and tried to link them, you’ll get this warning. You should compile all source files to use the same run-time library. See the Use Run-Time Library (MD, /ML, /MT, /LD) compiler options for more information.
You can use the linker’s /VERBOSE:LIB switch to determine which libraries the linker is searching. If you receive LNK4098 and want to create an executable file that uses, for example, the single-threaded, non-debug run-time libraries, use the /VERBOSE:LIB option to find out which libraries the linker is searching. The linker should print LIBC.LIB and not LIBCMT.LIB, MSVCRT.LIB, LIBCD.LIB, LIBCMTD.LIB, or MSVCRTD.LIB as the libraries searched. You can tell the linker to ignore the the incorrect run-time libraries by typing the incorrect libraries in the Ignore Libraries text box on the Link tab of the Settings dialog box in Developer’s Studio or by using the /NODEFAULTLIB:library option with LINK for each library you want to ignore. See the Ignore Libraries (/NODEFAULTLIB) linker option for more information.
The table below shows which libraries should be ignored depending on which run-time library you want to use.
To use this run-time library Ignore these libraries
Single-threaded (libc.lib) libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
Multithreaded (libcmt.lib) libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
Multithreaded using DLL (msvcrt.lib) libc.lib, libcmt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
Debug Single-threaded (libcd.lib) libc.lib, libcmt.lib, msvcrt.lib, libcmtd.lib, msvcrtd.lib
Debug Multithreaded (libcmtd.lib) libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, msvcrtd.lib
Debug Multithreaded using DLL (msvcrtd.lib) libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib
For example, if you received this warning and you want to create an executable file that uses the non-debug, single-threaded version of the run-time libraries, you could use the following options with the linker:
/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib
Subscribe to:
Posts (Atom)