Tuesday, July 17, 2012

Scrape email from yellow pages and send them email with 300 second delay


em = []
(1..63).each do |i|
yp = Nokogiri::HTML(open("http://www.yellowpages.com.my/search.jsp?sfor=all&name=logistic&w=&p=#{i}"))
emails = yp.search("a.email").map{|x| x["onclick"].gsub("SqueezeBox.open('/plainmail.jsp?id=", "").split("',")[0] }
emails.each do |eid|
  t = Nokogiri::HTML(open("http://yellowpages.com.my/plainmail.jsp?id=#{eid}"))
  em.push(t.search("input").first["value"])
end
InvoiceMailer.inquiry(em).deliver
sleep 300
end

Friday, July 13, 2012

GOD ruby gem for unicorn bundle exec configuration file example.


God.watch do |w|
  w.name = 'unicorn'
  w.interval = 30.seconds
  w.start = "cd #{rails_root} && bundle exec unicorn -c /home/system/deploy/akeyu/config/unicorn.rb -D"
  w.stop = "kill -QUIT `cat #{rails_root}/tmp/pids/unicorn.pid`"
  w.restart = "kill -USR2 `cat #{rails_root}/tmp/pids/unicorn.pid`"
  w.start_grace = 10.seconds
  w.restart_grace = 10.seconds
  w.pid_file = "#{rails_root}/tmp/pids/unicorn.pid"
  w.behavior(:clean_pid_file)
  w.start_if do |start|
    start.condition(:process_running) do |c|
      c.interval = 5.seconds
      c.running = false
    end
  end
end

Monday, July 9, 2012

nginx log file location from using brew installation

tail -f /usr/local/Cellar/nginx/1.0.10/logs/error.log and of course access.log

Saturday, July 7, 2012

ruby on rails daemon


akob:ceramahonline akob$ rails plugin install git://github.com/dougal/daemon_generator.git
Initialized empty Git repository in /Users/akob/hak/ceramahonline/vendor/plugins/daemon_generator/.git/
remote: Counting objects: 25, done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 25 (delta 2), reused 20 (delta 1)
Unpacking objects: 100% (25/25), done.
From git://github.com/dougal/daemon_generator
 * branch            HEAD       -> FETCH_HEAD
Daemon Generator
================

To get yourself rolling:
> sudo gem install daemons
> ./script/generate daemon

Then insert your code in the lib/daemons/.rb stub. All pid's and logs will live in the normal log/ folder.  This helps to make things Capistrano friendly.

Individual control script:
> ./lib/daemons/_ctl [start|stop|restart]

App-wide control script (I add this to my capistrano recipe's after_restart task):
> ./script/daemons [start|stop|restart]
akob:ceramahonline akob$

Key to SEO success

1. Title best describing content
2. meta description 2-3 sentence
3. meta keyword with comma forecasting user search behavior that relate with our content 3. used H1 only 1. and use other Hn as well
4. social networking, share, like, comment, +
5. short & readable URL

Thursday, June 21, 2012

my worth STRIVING for.

married & hv kids with her. buy house 4 mama. buy house 4 abah & look after him. my family is my everything my love is my requirement

Wednesday, June 6, 2012

rails gmail pop3 ssl reading email

require 'net/pop'
Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE)  
Net::POP3.start('pop.gmail.com', 995, username, password) do |pop|  
  if pop.mails.empty?  
    puts 'No mails.'  
  else  
    pop.each_mail do |mail|  
      p mail.header  
      p mail.pop  
    end  
  end  
end