Install PadWalker to Windows

To install Padwalker on your windows machine follow the steps:

I have PPM Version v4.10 and ActiveState perl v5.8.9
1. Download PadWalker-1.9.tar.gz it from CPAN
2. unzip and extract it to your Perllib folder (should find it over here C:Perllib)
3. In command line go to the extracted folder and execute: PPM install PadWalker

you have successfully installed Padwalker on windows


Get rid of the Google's smelling of your private info. (Alternatives)

I am the one of the internet users which is really unconfortable of the Google’s privacy violation. Thus I start to search on internet some alternatives to Google. Here what I found: (ALL THESE ENGINES DO NOT FOLLOW YOUR PRIVACY)

1- : It is relatively young search engine. It combines all the results from various well-known sources such as “Yahoo, Bing, Wikipedia, Wolfram..” also it runs it own crawler that digs deep side of the Internet that the major search engines does not realize. In addition it gives different keyword that can be use while you are typing your search keys. However one negative thing about the site is unfortunately it is relatively slower while showing the results.

2- : This site uses its own crawler and the results that comes from google. However it deletes all your personal info. like IP address while fetching results from google so they claim that google cannot trick over you. Another good think about the site, it gives you a shorthand bookmark option so that you can bookmark your results. Also it gives the result fast enough.

3- YaCy is a decentralized search engine that anyone can use to build a search portal for their intranet or to help search the public internet. All users of the search engine network are equal, the network does not store user search requests and it is not possible for anyone to censor the content of the shared index. You can download YaCy and install it on your device


Use yield in Ruby

yield function is one of the good stuff in the Ruby that gives different kind of code reuse logic to your code. It just like lambda in Scheme and Lips. when yield is called in a function it cuts the execution of its container function and pass the execution time to the do-end block then when the execution ends with the end keyword, it continues the execution from the last point.

Here is an example code that uses yield function.

def around_staff
  eren = 20
  puts "first step"
  puts "last step"

def do_something
  around_staff do |eren|
    puts "I did something around"+ eren.to_s


What Metaprogramming is…

Metaprogramming is coding some programs that generates new code segments to be executed while execution time. So why it is a need.

  • We determined which problems were best solved with a code-generating program, including:
    • Programs that need to pre-generate data tables
    • Programs that have a lot of boilerplate code that cannot be abstracted into functions
    • Programs using techniques that are overly verbose in the language you are writing them in
  • We then looked at several metaprogramming systems and examples of their use, including:
    • Generic textual-substitution systems
    • Domain-specific program and function generators
  • We then examined a specific instance of table-building
  • We then wrote a code-generating program to build static tables in C
  • Finally, we introduced Scheme and saw how it is able to tackle the issues we faced in the C language using constructs that were part of the Scheme language itself

I got familiar to this idea from the talk of a ruby programmer and here is the link to the video of that talk about how to metaprogramming in ruby.


What I've learned today : Sharding Database

Sharding database consept was founded before a decade however implementations have occurred with complex social networking apps and SaaS and actually it was coined by Google pratically.

Database Sharding can be simply defined as a “shared-nothing” partitioning scheme for large databases across a number of servers, enabling new levels of database performance and scalability achievable. If you think of broken glass, you can get the concept of sharding – breaking your database down into smaller chunks called “shards” and spreading those across a number of distributed servers.

The basic concept of Database Sharding is very straightforward: take a large database, and break it into a number of smaller databases across servers. The concept is illustrated in the following diagram:

Database Sharding

Figure 2. Database Sharding takes large databases and breaks them down into smaller databases.

The obvious advantage of the shared-nothing Database Sharding approach is improved scalability, growing in a near-linear fashion as more servers are added to the network. However, there are several other advantages of smaller databases, which should not be overlooked when considering a sharding solution:

  • Smaller databases are easier to manage. Production databases must be fully managed for regular backups, database optimization and other common tasks. With a single large database these routine tasks can be very difficult to accomplish, if only in terms of the time window required for completion. Routine table and index optimizations can stretch to hours or days, in some cases making regular maintenance infeasible. By using the sharding approach, each individual “shard” can be maintained independently, providing a far more manageable scenario, performing such maintenance tasks in parallel.
  • Smaller databases are faster. The scalability of sharding is apparent, achieved through the distribution of processing across multiple shards and servers in the network. What is less apparent is the fact that each individual shard database will outperform a single large database due to its smaller size. By hosting each shard database on its own server, the ratio between memory and data on disk is greatly improved, thereby reducing disk I/O. This results in less contention for resources, greater join performance, faster index searches, and fewer database locks. Therefore, not only can a sharded system scale to new levels of capacity, individual transaction performance is benefited as well.
  • Database Sharding can reduce costs. Most Database Sharding implementations take advantage of lower-cost open source databases, or can even take advantage of “workgroup” versions of commercial databases. Additionally, sharding works well with commodity multi-core server hardware, far less expensive than high-end multi-CPU servers and expensive SANs. The overall reduction in cost due to savings in license fees, software maintenance and hardware investment is substantial, in some cases 70% or more when compared to other solutions.

There is no doubt that Database Sharding is a viable solution for many organizations, supported by the number of large online vendors and SaaS organizations that have implemented the technology (giants such as Amazon, eBay, and of course Google).


Using active record (database) for session information storage

If you have a problem about the cookie size (4KB) in your application, you may use database storage help. With this manipulation your app will keep an id in cookie and store other information in “sessions” table in DB and it will call the data from table by the id that is kept in cookie.

First: Execute following (it will create the table structure that is ready to be migrated)

rake db:sessions:create

Second: It’ll create the table

rake db:migrate

Third: inside the config/initializers/session_store.rb add following

MyApp::Application.config.session_store :active_record_store

That s all folks…



Gem Error while try to execute Rails commads

to_specs': Could not find rails (>= 0) amongst [] (Gem::LoadError) from /usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:256:in

if you get such an error while execution “rails new [project_name]” it means there is a conflict on your machine between gem installations and you need to get rid one of them.

I just start to use rvm instead of plain ruby installation and there were an such error. As a solution I deleted the “site_ruby” folder in ~/opt/local/lib path, then everything is working fine


What I learnt about Ruby and Rails today?

Difference beween attr_accessor and attr_accesible:

attr_accessor is a ruby method that makes a getter and a setter. attr_accessible is a Rails method that allows you to pass in values to a mass assignment: new(attrs) or up update_attributes(attrs).

Here’s a mass assignment:{ :type => 'Corn', :quantity => 6 })

You can imagine that the order might also have a discount code, say :price_off. If you don’t tag :price_off as attr_accessible you stop malicious code from being able to do like so:{ :type => 'Corn', :quantity => 6, :price_off => 30 })

Even if your form doesn’t have a field for :price_off, if it’s just in your model by default it’s available so a crafted POST could still set it. Using attr_accessible white lists those things are can be mass assigned.