Monday, November 12, 2007

things to remember: network scanning tools, and painful ror select tags

i literally spent half day on using select_tag with options_for_select using ror.

in theory
<%= select_tag 'table_name[field_name]', options_for_select([array of options list],'what is inserted in table table_name field field_name as value') %>

to get the select list showing up w/ prepopulated data.

why spend whole half day?

hmm... well, the field i am trying to pre-populate have mysql db table with type enum. i think that's why it's not working for the category i am building. works for 'os' which have data type as string works after a few try. should i add '.to_i' to get the enum map to the integer value of the list? how stupid it feels. continue on hacking.

so far it works for:

<%= select_tag 'testtable[target_os]', options_for_select(["", "Windows", "OS X", "Linux"], @testtable.target_os) %>


<%= select_tag 'testtable[target_browser]', options_for_select(["", "Firefox", "IE", "Safari", "opera"], @testtable.target_browser) %>


@testtable = TestTable.find(params[:id])

in my controller's class method.

Oh, i also better not forget how to use ss and nmap.

'ss -l' in most cases and 'nmap -A -T4 hostname' tells me what ports i am using. not sure if it's weather or just banging my head of this select_tag, but it took me forever to remember these two. Actually I had to ask around for ss. What a monday...


Thursday, November 01, 2007

chasing leopard, ..., caught up on rmagick at least.

when i first got into ror(ruby on rails) earlier this year getting the system configured w/ ruby, rails, gem, and rmagick in particular was a pain, on my fedora core desktop.
then came along ubuntu's easy install guide followed by fedora core(5, 6 and onward)'s easy to install, with all those '*-dev' packages that contain all the libraries.

rmagick, in short, is imagemagick/graphicsmagick package for ruby-on-rail that ror developers use a lot.

well, with my environment setup nicely, and not being a heavy mac user i only enjoyed stuffed animal leopard at local mac sotres and didn't bother with mac os update. getting a bit too old to be caught up in flurry of hypes.

well, derek is a cool guy and he waited on the line on last friday to get leopard copy, along with free t-shirt, and installed it. now it comes with ruby, rubygem and rails, but not with rmagick or mysql. when he had no success and couldn't get his work done (for having clean installed the whole system on his mac book), i got volunteered in this morning. i mean yesterday morning. i spent good 5hours solid chasing gtk, librsvg and imagemagick-devel that may or may not exist. with gtk, the dependencies were about as greek to me as the gtk package itself. requires pango then requires cairo, but it reality gtk requires pango with cairo support. and then there is question of incompatible pkgconfig. what do you mean pkgconfig is too old? leopard is been out less than a week....

anyhow, i can't let rmagick defeat me, so i picked up a leopard copy and spent good 2+ hrs getting it on my precious mac mini, the one with dual boot partition of fedora core 6. why 2+ hours? takes about 45minutes, and i did it twice, because i messed up playing with boot camp and few other configs. with the install my rEFI bootloader is blown away. my linux partition is still there, but no bootloader to let me start with linux partition. sob, sob, sob... since boot camp is only compatible with windows os, and i have no room nor wish to delete current linux partition and reinstall(i actually was using my inux partition right up to the point i started inserting leopard dvd in, for installation).

unlike earlier the day i actually searched for rmagick installation how to, and got lucky. actually works.

some of urls didn't work so i had to manually download it. but steps are golden. i skipped ruby, rubygem and rails. i also used 'sudo gem install rmagick' instead of doing tar source install.

but it works.

i did 'cd rails/test/; script/console; require 'RMagick' ' and it worked. only took me what about 2+ hours, and another hour to copy over the list of tar files and instruction for derek?


thanks Josh Goebel. you saved me my sanity.

now i still gotta figure out why readline doesn't compile and why mysql server doesn't start from boot.

worst of all, i gotta figure out my dual boot.

but now i can sleep, finally, at 4am, for having rmagick working on my new shiney leopard os.

and, i can see some cool desktop features on leopard. through my sleepy slanted eyes.

pkgs i needed:
* pcre-7.4
* lighttpd-1.4.18
* freetype-2.3.4
* libpng-1.2.22
* jpegsrc.v6b
* tiff-3.8.2
* libwmf-
* lcms-1.17
* ImageMagick-6.3.6-4
* ghostscript-fonts-std-8.11 (when untar, goes to fonts dir instead of ghostscript-fonts dir)

steps from my home>Downloads folder terminal shell:
tar xvf pcre-7.4.tar
cd pcre-7.4
./configure --prefix=/usr/local CFLAGS=-01
make install
cd ..
tar xvf lighttpd-1.4.18.tar
cd lighttpd-1.4.18
./configure --prefix=/usr/local --with-pcre=/usr/local
make install
cd ..
tar zxvf freetype-2.3.4.tar.gz
cd freetype-2.3.4
./configure --prefix=/usr/local
make install
cd ..
tar xvf libpng-1.2.22.tar
cd libpng-1.2.22
./configure --prefix=/usr/local
make install
cd ..
tar xvf jpegsrc.v6b.tar
cd jpeg-6b/
ln -s `which glibtool` ./libtool
./configure --enable-shared --prefix=/usr/local
make install
cd ..
tar xvf tiff-3.8.2.tar
cd tiff-3.8.2
./configure --prefix=/usr/local
make install
cd ..
tar zxvf libwmf-
cd libwmf-
make clean
make install
cd ..
tar xvf lcms-1.17.tar
cd lcms-1.17
make clean
make install
cd ..
tar xvf ghostscript-fonts-std-8.11.tar
mkdir /usr/local/share/ghostscript
mkdir /usr/local/share/ghostscript/fonts
cp fonts/* /usr/local/share/ghostscript/fonts/.
tar xvf ImageMagick-6.3.6-4.tar
cd ImageMagick-6.3.6
export CPPFLAGS=/-I/usr/local/include
export CPPFLAGS=-I/usr/local/include
export LDFLAGS=-L/usr/local/lib
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts
make install
gem install RMagick

does it work? yes:
so far it looks okay on irb:
mac-mini:~ user$ cd rails/test/
mac-mini:test user$ script/console
Loading development environment.
>> require 'RMagick'
=> []