SapphireSteel :: Ruby In Steel

Curious to see how writing ruby code in visualstudio goes ?

Download
http://www.sapphiresteel.com/Ruby-In-Steel-New-Free-Edition
Download
http://ankhsvn.open.collab.net/
Install both

svn checkout your project to some directory. (c:\source)

Launch steel
Go to File -> New Project -> Import Project
Name your project
choose project location (c:\steel-project)
Go Next
Choose your project folder (place where you did svn checkout) (c:\source)
Check mark Rails Project checkbox
Click ok
Click Proceed
Wait.. it will take some time to copy files.
Done. You can start using your Steel PE now.

Use File -> Subversion menu to perform svn operations.
Optionally you can access SVN operations from Solutions tab also.

AOL rejecting or blocking emails

Recently, we faced a problem where emails generated from our application were not showing up in AOL inbox(es).

We have recently switched to a new machine & I suspected that for new machine mx-records are not set correctly from where I am trying to send the email.

We didn’t wanted to change our mx-records as we feared loosing any email. This is when SPF works.

http://www.openspf.org

We setup SPf records & this problem is solved. Now, our new machine is a valid email sender for our domain.

But emails were still not making it through AOL.

After some googling & aoling i found this link:

http://postmaster.info.aol.com/trouble/index.html

from here I followed this:

http://postmaster.info.aol.com/tools/telnet.html

I followed the instructions relegiously & got this error:

421-: (DNS:NR) http://postmaster.info.aol.com/errors/421dnsnr.html
421 SERVICE NOT AVAILABLE

URL: http://postmaster.info.aol.com/errors/421dnsnr.html clearly states the problem

So, reverse DNS is not set correctly.

AOL also provides this tool for further testing of your reverse DNS
http://postmaster.info.aol.com/cgi-bin/dns_tool.pl

We asked our hosting provider setup reverse DNS for our domain.

Damnnn.. Why didn’t we first looked at AOL faqs.

Wget came to my rescue

I was trying to download some 150-200 zip files from a http URL by finding each file & clicking on it to download.  I soon realized how boring it is using standard download support in browsers.

This is something I am supposed to do periodically

I know that there are some browser extensions available that could do this pretty easily, but i wondered if i could do this via command line & later on automate it somehow.

This is when i recalled wget.

I downloaded it for my machine from here

After some experimentation i finalized following working set for myself:

wget “http://somewebsiteyoutarget/folderx/foldery/” -r -A zip

Options Explanation:

-r : recursively digs the folder until it exhausts. There are options for specifying recursion levels too (see wget -h)

-A : you can specify extensions you want to download. In my case these are zip files only.

Since these files were quite big in size, it took some time to download these files. Occasionally my internet connection broke & i had to restart things again.

But wget has solution for these problems as well (see wget -h). I explored the help and found -c & -t options pretty usefull for crappy connections.

So now my command looks like this:

wget “http://somewebsiteyoutarget/folderx/foldery/” -r -A zip -c -t

Wget rocks (full marks) ! : o ) !

OpenSolaris: Problem Installing eventmachine gem

set this var before gem install command

export CXX=g++

Setup:: Rubyworks & rMagick

I tried this before mod_rails launched.

Pushing my command log for reference.

This setup uses rubyworks, details can be found here http://studios.thoughtworks.com/rubyworks
I tried this on a redhat machine. The setup seems to be working perfectly fine.
clear
2 ruby
3 yum install ruby
4 wget http://rubyworks.rubyforge.org/RubyWorks.i386.repo
5 sudo cp RubyWorks.i386.repo /etc/yum.repos.d/
6 uname -A
7 uname -a
8 yu update
9 yum update
10 yum install rubyworks
11 vi /etc/rails/haproxy.conf
12 /usr/sbin/sv restart haproxy
13 vi /etc/sysconfig/syslog
14 vi /etc/syslog.conf
15 service syslog restart
16 tail -fn200 /var/log/haproxy.log
17 tail -fn200 /var/log/haproxy.log
18 tail -fn200 /var/log/haproxy.log
19 ls
20 updatedb &
21 locate .pem
22 locate .pem
23 vi /etc/rails/monit.conf
24 /usr/sbin/sv restart monit
25 vi /etc/rails/monit.conf
26 /usr/sbin/sv restart monit
27 /usr/sbin/sv stop monit
28 gem list
29 gem install mysql
30 gem install mysql
31 vi /etc/hosts
32 cd /usr/rails/
33 ll
34 cd ..
35 ll
36 mv rails/ rails_skel
37 ll
38 mv /home/vivek/httpdocs.tar.gz .
39 tar -xzf httpdocs.tar.gz
40 ll
41 mv httpdocs rails
42 chown rails:rails rails
43 ll
44 chown -R rails:rails rails
45 cd rails_skel/
46 ll
47 cd public/
48 ll
49 vi dispatch.fcgi
50 cd ..
51 cd ..
52 cp rails_skel/public/dispatch.* rails/public/
53 cat rails_skel/config/environment.rb
54 cat rails_skel/config/environments/production.rb

cd log
57 ll
58 rm development.log
59 ll
60 echo ” > development.log
61 echo ” > mongrel.log
62 rm mongrel.pid
63 ll
64 ll
65 ls
66 /usr/sbin/sv
67 /usr/sbin/sv restart
68 /usr/sbin/sv restart mongrel
69 /usr/sbin/sv restart mongrel_*
70 /usr/sbin/sv restart mongrel_3002 mongrel_3003 mongrel_3004 mongrel_3005
71 ll
72 tail -fn200 development.log
73 ll
74 rm ferret_index
75 rm ferret_index.log
76 /usr/sbin/sv restart mongrel_3002 mongrel_3003 mongrel_3004 mongrel_3005
77 /usr/sbin/sv status mongrel_3002 mongrel_3003 mongrel_3004 mongrel_3005
78 /usr/sbin/sv restart haproxy
79 ls
80 cd ..
81 cd config/
82 ls
83 vi environment.rb
84 gem install ferret
85 gem install acts_as_ferret
86 gem install acts_as_ferret
87 vi environment.rb
88 gem install acts_as_ferret
89 gem install -r acts_as_ferret
90 gem install -r acts_as_ferret
91 gem install acts_as_ferret
92 gem install acts_as_ferret
93 wget http://rubyforge.org/frs/download.php/28079/acts_as_ferret-0.4.3.gem
94 cat /usr/lib/ruby/gems/1.8/source_cache | more
95 cd /usr/rails
96 cd config/
97 vi database.yml
98 cd ..
99 ruby script/server -p3002
100 /usr/sbin/sv start mongrel_3002 mongrel_3003 mongrel_3004 mongrel_3005
101 yum install ImageMagick
102 yum install ImageMagick-devel
103 gem install rmagick –source http://gems.rubyforge.org
104 gem install rmagick –source http://gems.rubyforge.org
cd config/
97 vi database.yml
98 cd ..
99 ruby script/server -p3002
100 /usr/sbin/sv start mongrel_3002 mongrel_3003 mongrel_3004 mongrel_3005
101 yum install ImageMagick
102 yum install ImageMagick-devel
103 gem install rmagick –source http://gems.rubyforge.org
104 gem install rmagick –source http://gems.rubyforge.org
105 cat /usr/lib/ruby/gems/1.8/gems/rmagick-1.15.11/gem_make.out | more
106 cd /usr/lib/ruby/gems/1.8/gems/rmagick-1.15.11
107 ll
108 ./configure
109 ruby setup.rb
110 ll
111 cat gem_make.out | more
112 cat config.log | more
113 cat config.log | more
114 cat config.log | more
115 locate imagemagick
116 vi config.log
117 yum install libtiff
118 yum install libtiff
119 yum install libtiff-devel
120 yum install libjpeg-devel
121 yum install libpng-devel
122 gem install rmagick –source http://gems.rubyforge.org
123 vi config.log
124 gem install rmagick –source http://gems.rubyforge.org
125 ll /usr/share/fonts
126 ll /usr/share/fonts/default/
127 ll /usr/share/fonts/default/Type1/
128 rpm -Uvf /home/vivek/msttcorefonts-1.3-4.noarch.rpm
129 ll /usr/share/fonts/default/
130 rpm -q msttcorefonts
131 rpm
132 rpm –whatprovides msttcorefonts-1.3-4
133 locate ttf
134 updatedb &
135 locate ttf
136 locate ttf
137 cd /usr/share/fonts/
138 ll
139 ll msttcorefonts/
140 pwd
141 cd default/
142 ln -s /usr/share/fonts/msttcorefonts/ TrueType
143 history
144 history | more
gem install rmagick –source http://gems.rubyforge.org

Successfully installed rmagick-1.15.11 YYAAAAYYYYYY

/usr/sbin/sv restart mongrel_3002 mongrel_3003 mongrel_3004 mongrel_3005

ERROR: While executing gem … (Gem::GemNotFoundException)

You might be feeling annoyed with this problem. (I do)
Problem could be:

your local source cache
Example:   /usr/lib/ruby/gems/1.8/source_cache

; try removing this file (Your path might be different than above given; check your path first using #gem env)
If this does not solves your problem

check your env var REMOTE SOURCES (#gem env)

If it is not gems.rubyforge.org then use following command to install:

#gem install -r gem_name  –source http://gems.rubyforge.org

If this does not solves your problem(is your internet down?)

Borrow gem files from your friend and install them without -r option.

#gem install /path_to/gemname.gem

/bin/rm: Argument list too long tmp/sessions/ruby_sess.*

Well this happens when there are too many files to process:
Best way in this case is to do batch processing:
Sample command:
find . -name 'ruby_sess.*' -print0 | xargs -0 rm

lynx: https how to

step1: Compile lynx with ssl support

cd lynx source folder

./configure –with-ssl

step2:  make ; make install

To avoid local ssl error prompts/complains,  Open lynx.cfg make following change:

step3:  FORCE_SSL_PROMPT:yes

thats all!. you should be able to crawl https pages using lynx now.

mpgtx: MPEG splitting made easy

Considering ffmpeg for mpeg cutting/splitting… too complex i think for such a simple task.

mpgtx.sourceforge.net is the way to go if are looking for simple operations like cutting/joining mpeg files.

Tool Summary :

This simple command(from a ruby script I wrote) will cut the full length videos into count_chunks pieces and store them under directory_writable, where count_chunks and directory_writable are both variables

Open3.popen3(”/bin/mpgtx -#{count_chunks} #{_file_to_process} -f -b #{directory_variable}/#{game.file_path.gsub(’.mpg’,”)} 2>> #{directory_variable}/split.log”)

RAILS_ROOT

RAILS_ROOT gives you relative path within the applications it works fine as far as you need the path within rails application.

How about getting absolute path to rails folder?

I found one way, and thats from the ENV hash.

You can use ENV['PWD'] to find absolute path to the rails folder.
Any other ways ??

*Update 4th Oct 2007*

Dir.pwd is a better way