Saturday, December 22, 2012

Sinus cause by humidity

Thursday, October 25, 2012

replace string using grep and sed with help of xargs

grep -r "Wholesale Quran" * | cut -f1 -d ':' | xargs sed -i 's/Wholesale Quran/I-Furqan Quran/g' $0

Wednesday, October 3, 2012

Cheap construction method & material

interlocking soil cement blocks

IRIS KOTO Building System - House Built in 7 Days.
The core if each panel is made by styrofoam

Beatiful home made by interlocking red brick

Thursday, July 26, 2012

Scraping mobile phone number from web"td").each do |e|
e = e.inner_html
if e.length > 10
tmp = e.gsub(/(\r|\n|\t|\D)/, "")

tmp.split(/(010|012|013|016|014|017|018|019)/).each do |s|
if s =~ /(010|012|013|016|014|017|018|019)/
pos = tmp =~ /#{s}/
#puts pos
if pos
number = "#{s}#{tmp[pos+3..pos+9]}"
puts number
Contact.create(:group_id => 1, :phone => number) if number.length == 10


Tuesday, July 17, 2012

scraping pictures at

agent =
cookie ="PHPSESSID" , "460a4eac8d62000529e894727c32bd31") #take session from ur web browser :P
cookie.domain = ""
cookie.path = "/"
agent.cookie_jar.add(agent.history.last.uri, cookie)

(1..466).each do |i|
web = Nokogiri::HTML(open("{i}&se=a%3A11%3A%7Bs%3A4%3A%22nSex%22%3Bs%3A1%3A%220%22%3Bs%3A5%3A%22nAge1%22%3Bs%3A2%3A%2218%22%3Bs%3A5%3A%22nAge2%22%3Bs%3A2%3A%2260%22%3Bs%3A8%3A%22nHeight1%22%3Bs%3A3%3A%22140%22%3Bs%3A8%3A%22nHeight2%22%3Bs%3A3%3A%22200%22%3Bs%3A8%3A%22nWeight1%22%3Bs%3A2%3A%2240%22%3Bs%3A8%3A%22nWeight2%22%3Bs%3A3%3A%22200%22%3Bs%3A7%3A%22nStatus%22%3Bs%3A1%3A%220%22%3Bs%3A10%3A%22nStateFrom%22%3Bs%3A2%3A%2299%22%3Bs%3A9%3A%22nStateNow%22%3Bs%3A2%3A%2299%22%3Bs%3A5%3A%22order%22%3Bs%3A5%3A%22dLast%22%3B%7D&PHPSESSIONID=460a4eac8d62000529e894727c32bd31"))".picborder").each do |x|
filename = x['src'].gsub("","")
url = x['src'].gsub("thumb1/", "img.php?display=")
puts filename, 'w+') do |file|
     file << agent.get_file(url)

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

em = []
(1..63).each do |i|
yp = Nokogiri::HTML(open("{i}"))
emails ="").map{|x| x["onclick"].gsub("'/plainmail.jsp?id=", "").split("',")[0] }
emails.each do |eid|
  t = Nokogiri::HTML(open("{eid}"))
sleep 300

Friday, July 13, 2012

GOD ruby gem for unicorn bundle exec configuration file example. do |w| = '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/`"
  w.restart = "kill -USR2 `cat #{rails_root}/tmp/pids/`"
  w.start_grace = 10.seconds
  w.restart_grace = 10.seconds
  w.pid_file = "#{rails_root}/tmp/pids/"
  w.start_if do |start|
    start.condition(:process_running) do |c|
      c.interval = 5.seconds
      c.running = false

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://
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://
 * 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.start('', 995, username, password) do |pop|  
  if pop.mails.empty?  
    puts 'No mails.'  
    pop.each_mail do |mail|  
      p mail.header  
      p mail.pop  

Thursday, May 24, 2012

Deploying multiple Rails Application using Nginx and Unicorn on the same port, different host

Dalam tutorial ini Ya'kob akan menerangkan bagaimana untuk membuat nginx supaya melayan request dari port yang sama, tapi host yang berlainan untuk applikasi rails yang berlainan. Ya'kob tidak menerangkan kaedah instalasi rails environment disini, kerana Ya'kob telah membuatnya didalam tutorial sebelumnya. Kita andaikan directory rails anda adalah di /home/system/deploy/akeyu Kita mahu meng-install webserver nginx
sudo apt-get install nginx
dan hidupkan nginx dengan service
sudo service nginx start
sila layari host anda dan sepatutnya anda dapat melihat "Welcome to nginx!" file config nginx terletak di /etc/nginx/nginx.conf sila perhatikan file tersebut untuk mempelajari kaedah pengoperasian nginx, contohnya untuk pelajari dimana log filenya untuk tujuan troubleshoot pada masa hadapan. nota + : seperti yang ditunjuk dalam railscast, kita mahu menyimpan file config nginx didalam folder rails application dan meng-symlink-nya untuk tujuan kemudahan mobility app tersebut cth: dengan penggunaan repository untuk digunakan pada lain2 server. Pada pendapat Ya'kob, ianya tidak sesuai untuk multiple application kerana kita mahu meng-config rails app yang lain juga didalam file config yang sama. Maka kita tinggalkan struktur file config nginx seperti asal.

nginx + webrick proof of concept

tuliskan di /etc/nginx/sites-enabled/default :
server {
 listen 80 default;
 # server_name;
 root /home/system/deploy/akeyu; 
 try_files $uri/index.html $uri @unicorn;
 location @unicorn {
   proxy_pass http://localhost:3000;
dan restart nginx
sudo service nginx restart
kemudian run webrick server
bundle exec rails s
layari http://localhost:3000 dan sepatutnya anda dapat melihat "Welcome aboard You’re riding Ruby on Rails!"

Keganasan bermula..

instalasi unicorn
gem 'unicorn'
working_directory "/home/system/deploy/akeyu"
pid "/home/system/deploy/akeyu/tmp/pids/"
stderr_path "/home/system/deploy/akeyu/unicorn/unicorn.log"
stdout_path "/home/system/deploy/akeyu/unicorn/unicorn.log"

listen "/tmp/unicorn.akeyu.sock"
worker_processes 2
timeout 30
berikut adalah contoh file /etc/nginx/sites-enabled/default Ya'kob.
upstream unicorn {
  server unix:/tmp/unicorn.akeyu.sock fail_timeout=0;

upstream place {
  server unix:/tmp/ fail_timeout=0;

server {
 listen 80;
 root /home/system/deploy/place/public;
 try_files $uri/index.html $uri @place;
 location @place {
   proxy_pass http://place;
 error_page 500 502 503 504 /500.html;

server {
 listen 80 default;
 root /home/system/deploy/akeyu/public;
 try_files $uri/index.html $uri @unicorn;
 location @unicorn {
   proxy_pass http://unicorn;
 error_page 500 502 503 504 /500.html;
sila restart nginx supaya perubahan config mula berkesan.
sudo service nginx restart
perhatikan nginx listen kepada port yang sama untuk kedua-dua server, tetapi akan bertindak berlainan cara jika diakses dari host yang berlainan. root dan try_files pula adalah untuk tujuan melayan (serve) file static jika ada dan @unicorn atau @place pula adalah untuk serve dari rails application. location adalah dimana nginx dan unicorn dihubungkan. unicorn akan menghasilkan sock pada /tmp apabila di run. Oleh itu kita menulis sock yang dihasilkan oleh unicorn pada bahagian location ini. seperti app yang pertama Ya'kob membuat 1 lagi app bernama place, menggunakan unicorn dan mengedit file /config/unicorn.rb sama seperti app akeyu. tetapi Ya'kob gantikan semua akeyu dengan place. pastikan directory betul. PENTING !: seperti isu Ya'kob, Ya'kob perlu untuk
chmod +w tmp/pids/ unicorn/ 
dalam folder app kita. sila create jika tidak wujud. run unicorn pada root application folder anda contoh di /home/system/deploy/akeyu
bundle exec unicorn -c config/unicorn.rb -D
dan juga pada direktori applikasi yang 1 lagi. dalam kes Ya'kob place jika tiada error dipaparkan, bermakna ianya telah berjaya di-run unicorn pada default-nya ia menyediakan 2 worker instance dan 1 master untuk melayan 3 client pada 1 serentak. Ia juga berkemampuan bertindak sebagai load balancer tetapi yakob belum mempelajarinya lagi. dan sekarang jika anda melayari dan anda telah mengakses 2 applikasi yang berbeza pada port yang sama. sebagai proof of concept, anda juga boleh menggunakan webrick pada salah satu applikasi. contoh config nginx
server {
 listen 80;
 root /home/system/deploy/place/public;
 try_files $uri/index.html $uri @place;
 location @place {
#   proxy_pass http://place;
    proxy_pass http://localhost:3000; #webrick perlu di-run pada port lain dari 80 untuk mengelakkan bind access port 80 error
 error_page 500 502 503 504 /500.html;
dan run webrick anda pada port 80 dan -d detach / sbgai service
rails s -p80 -d
selamat mencuba! dan tolong beritahu apa penemuan yang anda alami/ kesalahan pada tutorial ini / kelemahan / ketidak fahaman dalam tutorial ini / sebarang ralat.

Monday, May 21, 2012

storing backbone data inside dom element using jquery and retrieve it.

storing: $("#zone_data").data('zone', z.toJSON()) retrieving $("#zone_data").data('zone') z.toJSON() is a backbone model.

Monday, May 14, 2012

how to use find in unix

find ~/dnscell_projects/dnscell/app/assets/javascripts/ -name *orig -print

Tuesday, May 8, 2012

Backbone passing value to views

var view = new SentenceView({model: sentence}); var rendered = this.template(this.options.model.toJSON());

Tuesday, May 1, 2012

Deleteting All Facebook friend programmatically using fb graph api, mobile fb site, & jQuery + firequery

  url: "", // get this at take the Friends link and replace it.
  success: function(data) {
        jQuery.each(, function() {
                url: "",
                data: $("form:first").serialize(),
                type: "post"
  dataType: "json"
Use the fb mobile page (where we have confirm delete friend button) to execute this script.

We need firebug & firequery to jquerify this page before we can execute this script.

Basically, this script will fetch your friend id from the fb graph api & submit the confirm delete friend form using each friend id that it fetched.

Tuesday, April 17, 2012

backbone collection view example

var Appointment = Backbone.Model.extend({});

var AppointmentList = Backbone.Collection.extend({
  model: Appointment

var AppointmentView = Backbone.View.extend({
  template: _.template('">' +
                        '<%= title %>' +

  render: function(){
    return this;

var AppointmentListView = Backbone.View.extend({
  render: function(){
    this.collection.forEach(this.addOne, this);
  addOne: function(model){
    var appointmentView = new AppointmentView({model: model})

Backbone Basic

var Appointment = Backbone.Model.extend({});
var appointment = new Appointment();
appointment.set('title', 'My knee hurts');
var AppointmentView = Backbone.View.extend({
  render: function(){
  • ' + this.model.get('title') + '
  • '); } }); var appointmentView = new AppointmentView({model: appointment}); appointmentView; appointmentView.render() $('#app').html(appointmentView.el);

    Monday, March 19, 2012

    Comparison between ruby if and unless

    1.9.2-p290 :035 > unless false
    1.9.2-p290 :036?>   puts 'a'
    1.9.2-p290 :037?>   else
    1.9.2-p290 :038 >     puts 'b'
    1.9.2-p290 :039?>   end
     => nil
    1.9.2-p290 :040 > if false
    1.9.2-p290 :041?>   puts 'a'
    1.9.2-p290 :042?>   else
    1.9.2-p290 :043 >     puts 'b'
    1.9.2-p290 :044?>   end

    Thursday, February 23, 2012

    Ruby: concept of paginating

     paginating an array

    Proof of Concept:

    Preparing dummy array :
    test = []
    1.9.2p290 :053 > (1..50).each do |g|
    1.9.2p290 :054 > test += [g]
    1.9.2p290 :055?> end
    => 1..50
    1.9.2p290 :056 > test
    => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]

    We know that test[1..5] will return [1, 2, 3, 4, 5] of elements.

    Function to get the item number by 5 item per page.

    1.9.2p290 :061 > def item_number page
    1.9.2p290 :062?> perpage = 5
    1.9.2p290 :063?> margin = perpage * (page - 1)
    1.9.2p290 :064?> start = margin + 1
    1.9.2p290 :065?> ending = page * perpage
    1.9.2p290 :066?> return start..ending
    1.9.2p290 :067?> end

    Using the function to get page number 4

    1.9.2p290 :069 > test[item_number 4]
    => [17, 18, 19, 20, 21]

    happy arraying!

    Javascript wildcard Search in array using jQuery

    function search_array(a, query_value){
     keke = $.map(a, function (value) {
      re = RegExp(query_value, "gi");
      if(value.match(re)) return value;
      return null;
     return keke

    usage :
    >>> search_array(["gula", "gila", "abu"], "la")
    ["gula", "gila"]
    which im searching for string "la"