Find file
Fetching contributors…
Cannot retrieve contributors at this time
793 lines (606 sloc) 33.4 KB
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="">
<title><![CDATA[Fran on Rails]]></title>
<link href="" rel="self"/>
<link href=""/>
<name><![CDATA[Francisco J. Casas]]></name>
<generator uri="">Octopress</generator>
<title type="html"><![CDATA[Introducing the debugger-rails gem]]></title>
<link href=""/>
<content type="html"><![CDATA[<p>I&#8217;m a big fan of debugging. I find it a good tool to help you while writing
code and I use it a lot. However, it can be a bit annoying to debug rails
applications when you are running them on a web server like Passenger or Pow.</p>
<p>That&#8217;s why most of the times I use the great
<a href="">rack-debug</a>, which makes it possible to
debug this kind of applications.</p>
<p>The only problem with <strong>rack-debug</strong> is that you need to set it up every time
you want to use it on a new Rails application, thats why I created
<a href="">debugger-rails</a>, to do all this for
<p>The only thing <strong>debugger-rails</strong> does is to follow the instructions on the
<strong>rack-debug</strong> README and uses a railtie to insert the middleware and the rake
task in Rails.</p>
<p>If you want to know more about <code>rack-debug</code> (or debugging ruby code in general)
you can see <a href="">my small tutorial</a>.</p>
<title type="html"><![CDATA[How to use Twitter bootstrap with simple_form]]></title>
<link href=""/>
<content type="html"><![CDATA[<p><strong>Edit 2012-07-03</strong>: As you can see in the comments, simple_form has build it support for
bootstrap. And built in a much better way than this. Check the
<a href="">wiki</a>
to see how to make it work.</p>
<p>At Zorros we love <a href="">Twitter’s bootstrap</a>. It’s easy to use and perfect to start
your new applications with a good result. It provides some basic CSS tools
like a grid system together with some other fancy things.</p>
<p>However it has a small problem. You cannot make it work with a Rails
application out of the box. Don’t worry, it’s not a big problem. You can make
it work with just a bit of hacking here and there.</p>
<p>This are the minimum config options that I’ve found that you need on
simple_form to have it working with bootstrap so that it applies the right
classes. On fields and wrappers.</p>
<div><script src=''></script>
<noscript><pre><code># config/initializer/simple_form.rb
SimpleForm.setup do |config|
config.hint_class = &quot;hint input&quot;
config.error_class = 'error input'
config.wrapper_class = :clearfix
config.wrapper_error_class = :error
<p>We’re almost there… there’s one more step needed. Bootstrap uses an extra div
container around each input field. I’m afraid I couldn’t find any way to add
this extra wrapper with simple_form, so I ended up with this patch.</p>
<div><script src=''></script>
<noscript><pre><code># config/initializer/simple_form_bootstrap.rb
SimpleForm::Inputs.constants.each do |klazz|
next if klazz == :Base
&quot;SimpleForm::Inputs::#{klazz.to_s}&quot;.constantize.class_eval do
def input_with_surrounding_div
@builder.template.content_tag :div, input_without_surrounding_div, :class =&gt; &quot;input&quot;
alias_method_chain :input, :surrounding_div
<p>So far it works well, we couldn&#8217;t find any caveats yet… but if you do, or if
you find a better way to integrate these pieces of amazing soft, please let me
<title type="html"><![CDATA[Zorros has a vacancy]]></title>
<link href=""/>
<content type="html"><![CDATA[<p><strong>Update</strong> 2011-08-15: We finally covered the vacancy. If you want further info
you can read it at the <a href="">Zorros&#8217; blog post</a>.</p>
<p>Apparently our clients like our work a lot. They like our work so much that we
are looking for a Zorro to join our team. Zorros is developing web applications
and business software, and is looking for an extra developer. Do you recognize
yourself in the following profile description?</p>
<li>Your passion is IT</li>
<li>You love the web and innovation</li>
<li>You like to solve problems using software</li>
<li>You know how to collaborate in a team</li>
<li>You can work from home</li>
<li>You can manage your own planning and freedom</li>
<li>You have been coding a lot (which language is not important)</li>
<li>You know some basics about UI and design</li>
<li>You are a problem solver</li>
<li>You love coding, but are not too proud to do other web agency related work.</li>
<li>English is not a problem for you.</li>
<p>We&#8217;d like to talk with you! Please contact us at hello[at]zorros[dot]be
Note: if you know these words, you definitively have a plus:</p>
<li>Rails &amp; Ruby</li>
<li>DRY &amp; conventions</li>
<li>HAML &amp; Sass &amp; CSS</li>
<li>VIM &amp; TextMate</li>
<li>JSON &amp; XML</li>
<li>JQuery &amp; prototype</li>
<li>Saas &amp; Freemium</li>
<li>Git &amp; Terminal</li>
<li>*nix (Linux, MacOSX, etc&#8230;)</li>
<p>You can find more info about us in our website: <a href=""></a></p>
<title type="html"><![CDATA[Rails debug with passenger]]></title>
<link href=""/>
<content type="html"><![CDATA[<p><strong>Edit 2012-07-05:</strong> You can now install <code>rack-debug</code> in a much more easy way by
using my <a href="">debugger-rails</a> gem.</p>
<h2>Without Passenger</h2>
<p>In my last post we learned <a href="">how to debug ruby scripts</a>. It can be done
as well with a rails application, you just have to start it with <code>script/server
-u</code>. The <code>-u</code> means to start on debug mode. Just make sure you have the
<code>ruby-debug</code> gem installed.</p>
<h2>With Passenger</h2>
<p>That works amazing&#8230; unless you use Passenger on development. If you do, then
you&#8217;ll need a different way to run the debugger. Don&#8217;t panic, it&#8217;s quite easy,
thanks to the <a href="">rack-debug</a> gem.
Rack::Debug is a gem which provides an easy interface to <code>ruby-debug</code> for
applications running on Passenger. And the good thing about it is that&#8230; it
just works!</p>
<p>To use it, just add the <code>ruby-debug</code> gem to your Gemfile, make sure to use the
<a href="">1.4.x version</a> if you&#8217;re
running ruby 1.8.x, since the new <a href="">2.x version</a> is prepared for ruby 1.9.2.</p>
<div><script src=''></script>
<noscript><pre><code># Gemfile
# For ruby 1.8
gem &quot;rack-debug&quot;, &quot;~&gt; 1.4&quot;, :group =&gt; :development
# For ruby 1.9.2
gem &quot;rack-debug&quot;, :group =&gt; :development</code></pre></noscript></div>
<p>Now that your gem is installed, add the middleware to Rails.</p>
<div><script src=''></script>
<noscript><pre><code># config/environments/development.rb
require &quot;rack/debug&quot;
config.middleware.use &quot;Rack::Debug&quot;</code></pre></noscript></div>
<p>And the helper rake tasks.</p>
<div><script src=''></script>
<noscript><pre><code># Rakefile
require 'rack-debug/tasks' if Rails.env.development?</code></pre></noscript></div>
<p>Now you can just add a <code>debugger</code> statement on any line on your application,
restart it and run <code>rake debug</code> so that the Rack::Debug gem connects to the
debugger. Easy, eh?</p>
<p>Enjoy the debugging!</p>
<title type="html"><![CDATA[How to debug a ruby script]]></title>
<link href=""/>
<content type="html"><![CDATA[<p>Debugging rules. Maybe you&#8217;re trying to find an elusive bug or how that
spaghetti piece of code works, in any case is a quite powerful tool and you
should add it to your day to day job.</p>
<p>Debugging in ruby is easy&#8230; and you don&#8217;t even need a GUI for it! Ruby has the
amazing <code>ruby-debug</code> gem. That gem provides an executable to debug your ruby
software. There&#8217;re versions for ruby 1.8.x and ruby 1.9.x. I will explain here
how to install and use the version for ruby 1.8, but ruby 1.9 version is quite
<p>First install the gem with <code>gem install ruby-debug</code>. This will give you an
executable called <code>rdebug</code> which executes the ruby interpreter in debug mode
allowing you to debug your script.</p>
<p>I will use this small script to debug.</p>
<div><script src=''></script>
<noscript><pre><code>dude = true
if dude
puts &quot;Hey dude&quot;
puts &quot;Hello world&quot;
<p>Now we can just run the debugger with <code>rdebug small_script.rb</code>. And&#8230; voila!</p>
<div><script src=''></script>
<noscript><pre><code>[-4, 5] in /projects/889122/small_script.rb
=&gt; 1 dude = true
3 if dude
4 puts &quot;Hey dude&quot;
5 else
dude = true
<p>Here you can see the debugger.</p>
<p>Here&#8217;s the file in which you&#8217;ve stopped:
<code>[-4, 5] in /projects/889122/small_script.rb</code></p>
<p>This arrow indicates that you&#8217;re stopped there:
<code>=&gt; 1 dude = true</code></p>
<p>And this is the rdebug console where you can give commands to the debugger.:
<code>(rdb:1) _</code></p>
<p>Let&#8217;s give it a quick try to see how the commands work. Type <code>help</code> and press
<div><script src=''></script>
<noscript><pre><code>ruby-debug help v0.10.4
Type 'help &lt;command-name&gt;' for help on a specific command
Available commands:
backtrace delete enable help method putl set trace
break disable eval info next quit show undisplay
catch display exit irb p reload step up
condition down finish kill pp restart thread var
continue edit frame list ps save tmate where</code></pre></noscript></div>
<p>As you can see there&#8217;re plenty of commands in the debugger, those ones you will
use them a lot.</p>
<li><strong>next</strong> (you can use it shortened as <code>n</code> as well) will make the
script go one step forward.</li>
<li><strong>continue</strong> (shortened as <code>c</code>) will make the script continue until it
finds a breakpoint.</li>
<li><strong>step</strong> (shortened as <code>s</code>) will step into a method.</li>
<li><strong>break</strong> (shortened as <code>b</code>) sets a breakpoint with the format <code>b
file_name.rb:XX</code> where XX is the line number.</li>
<p>For everything else&#8230; I encourage you to spend 15 minutes reading each command
help 1 by 1. Special mention to <code>irb</code>, <code>where</code>, <code>up</code> and <code>down</code> commands.</p>
<p>Enjoy your debugging!!</p>
<title type="html"><![CDATA[PayPal on Rails]]></title>
<link href=""/>
<content type="html"><![CDATA[<p>After many searches in Google I found many explanations on how to use PayPal,
however any of them did what I exactly needed. So here&#8217;s what I did step by
step last time I needed it.</p>
<h2>How PayPal works</h2>
<p>Take a look at this flow diagram:</p>
<p><img src="" title="PayPal WPS" ></p>
<li>The buyer goes to PayPal and performs the needed payment. (This is steps
1 and 2 in the diagram)</li>
<li>PayPal takes the payment and redirects your buyer back to your
application. (steps 3 and 4)</li>
<li>Some time after that, PayPal will send you a callback response with the
details of the received payment. Your application will use those details to
make sure the payment was OK and mark the order as paid. (Steps 5 and 6)</li>
<h2>Set up your PayPal sandbox</h2>
<li><p><a href="">Sign up here</a> To get a sandbox account. This
account will allow you to handle your development tools:</p>
<li><strong>Seller and buyer mock accounts</strong>: That way you can test your payments
without need to use a real account/bank account/credit card.</li>
<li><strong>IPN (Instant Payment Notification) testing</strong>: This is the way that
PayPal informs your application when the payment is done.</li>
<li><p>Create a seller and buyer mock accounts. Preconfigured seller accounts
failed for me, they always failed for me 100% of times in a period of many
months. I&#8217;m quite sure it&#8217;s my fault, but I just couldn&#8217;t find enough info to
know what I did wrong.</p></li>
<h2>Set up your application</h2>
<h3>Install ActiveMerchant.</h3>
<p>Here it came my second big problem. Just couldn&#8217;t figure out how to make it
work in the form of a gem. So I finally had to install it as a plugin.
<code>rails plugin install git://</code></p>
<p>From the above diagram you application will need to:</p>
<li>Be able to send payment details to PayPal.</li>
<li>Receive a callback from PayPal to acknowledge the received payment.</li>
<p>And here&#8217;s where ActiveMerchant enters. It provides a helper to craft a form
with the needed hidden fields which you will send to PayPal and a class with
the needed logic to receive and validate the callback from PayPal.</p>
<h3>Configure Active Merchant</h3>
<p>Set up an initializer file like <code>config/initializers/active_merchant.rb</code> with
the following content (it explains itself&#8230; isn&#8217;t it?):</p>
<div><script src=''></script>
<noscript><pre><code># config/initializer/active_merchant.rb
if Rails.env.production?
ActiveMerchant::Billing::Base.mode = :test
<h3>Set up the PayPal button</h3>
<p>Use something like that to generate the button that your user has to push so
that he makes the payment.</p>
<div><script src=''></script>
<noscript><pre><code>&lt;!-- app/views/payment/new.html.erb --&gt;
&lt;% payment_service_for, PAYPAL_ACCOUNT,
:amount =&gt; @order.price, :currency =&gt; 'EUR',
:service =&gt; :paypal do |service|
service.customer :first_name =&gt;,
:last_name =&gt; current_user.surname,
:email =&gt;
service.item_name @order.items_summary
# PayPal will POST a callback here when the payment is done
service.notify_url notifications_url(@order)
# PayPal will take your user here with a POST after he pays
service.return_url paypal_return_notifications_url(@order)
# PayPal will redirect your user here if he cancels the payment
service.cancel_return_url paypal_cancel_notifications_url(@order) %&gt;
&lt;%= submit_tag 'Pay this order' %&gt;
&lt;% end %&gt;
<p>If you need to send more info to PayPal take a look at the ActiveMerchant&#8217;s doc
or even at its code, to see which options are accepted by the
<code>payment_service_for</code> helper. Just FYI, the helper doesn&#8217;t support multiple
items. In case you need it you&#8217;ll need to craft your own helper&#8230; and maybe
send a pull request to ActiveMerchant ^<sup>.</sup></p>
<h3>Gather and acknowledge the PayPal response</h3>
<p>PayPal will send you a notification so you can know when the order is paid.
This following code is a sample of how this can be done.</p>
<div><script src=''></script>
<noscript><pre><code># app/controllers/notifications_controller.rb
class NotificationsController &lt; ApplicationController
include ActiveMerchant::Billing::Integrations
protect_from_forgery :except =&gt; [:create, :paypal_return]
# This action is for when the buyer returns to your site from PayPal
def paypal_return
flash[:notice] = &quot;Thanks for buying this!&quot;
redirect_to root_path
# This action is for when the buyer cancels
def paypal_cancel
flash[:notice] = &quot;We're sorry you didn't buy :(&quot;
redirect_to root_path
# This is what will receive the IPN from PayPal
def create
# You maybe want to log this notification
notify = request.raw_post
@order = Order.unpaid.find(notify.item_id)
if notify.acknowledge
# Make sure you received the expected payment!
if notify.complete? and @order.price == params[:mc_gross] )
# All your bussiness logic goes here
@order.update_attributes(:paid =&gt; true)
render :nothing =&gt; true
#Make sure you log the exceptions you have.
<h2>That&#8217;s all folks!</h2>
<p>This is the most simple way I found to make PayPal work with ActiveMerchant.
However it&#8217;s very limited and lacks support for things like multiple items and
data encryption between your app and PayPal. Unluckly ActiveMerchant lacks
support for these two things on its PayPal integration. However you can achieve
this by using something <a href="">like that</a>.</p>
<p>If you find some stupid thing or some bug here, just let me know so that I can
fix it :)</p>
<title type="html"><![CDATA[Paperclip as a gem]]></title>
<link href=""/>
<content type="html"><![CDATA[<p><strong>Edit 2012-07-04:</strong> You won&#8217;t have those problems with latest rails and
paperclip. As far as I know this only happens with rails 2.</p>
<p>I love <a href="">paperclip</a>. To be clear it just
works. It makes what it has been designed for and makes it easy and flexible
enough to do some other things.</p>
<p>However, there&#8217;s something with paperclip that always disappoints me, it have
some problems when you want to install it as a gem, and, in my case, when you
want to use it with <a href="">bundler</a>.</p>
<p>The problem is that it doesn&#8217;t load the rake tasks nor the should macros.
Shoulda macros are loaded without problem if the gem is vendored in the project
dir, since shoulda will look for it. But to load the macros when not vendored
you need the following code on your <code>test_helper.rb</code> just before <code>class ActiveSupport::TestCase</code>.</p>
<div><script src=''></script>
<noscript><pre><code>require File.expand_path(File.join(Gem.datadir('paperclip'), '..', '..', 'shoulda_macros', 'paperclip.rb'))
class ActiveSupport::TestCase
# ...
# here comes your custom test options
<p>That way the macros are properly load and you can use them on your tests.</p>
<p>To load the rake tasks you need a similar approach. Just include this line in
your Rakefile. If you&#8217;re using Rails 3 it will properly load automatically the
rake tasks for you so no need for this trick.</p>
<div><script src=''></script>
<noscript><pre><code>#Newest versions
import File.expand_path(File.join(Gem.datadir('paperclip'), '..', '..', 'lib', 'tasks', 'paperclip.rake'))
# Versions older than 2.3.2
import File.expand_path(File.join(Gem.datadir('paperclip'), '..', '..', 'tasks', 'paperclip_tasks.rake'))</code></pre></noscript></div>
<title type="html"><![CDATA[One step further]]></title>
<link href=""/>
<content type="html"><![CDATA[<p>The last week I dropped my job at <a href="">Nuatt</a> and started a
new professional adventure as a freelance developer together with the excellent
guys from <a href="">Zorros</a>.</p>
<p>My main role will be developing Ruby on Rails applications to boost others&#8217;
business as well as helping with improving <a href="">Fikket</a> which
is an excellent solution to publish your events online and sell the tickets
without effort.</p>
<p>I&#8217;m quite sure that this new adventure will be really interesting and will
bring lots of fun.</p>
<p>BTW, just in case you don&#8217;t know &#8220;zorro&#8221; means &#8220;fox&#8221; in Spanish.</p>
<p>You can find Zorros on <a href="">Facebook</a> and
<a href="">Twitter</a></p>
<title type="html"><![CDATA[dotfiles]]></title>
<link href=""/>
<content type="html"><![CDATA[<p>I&#8217;ve just put my <a href="">dotfiles</a> in a GitHub
repository. It&#8217;s just s simple collection of configuration files and a rake
task to install them together with
<a href="">oh-my-zsh</a>.</p>
<p>It includes as well some nice tools taken from other dotfiles I&#8217;ve found
searching on GitHub. If you like it just fork it change it and use it :)</p>
<p>Do you&#8217;ve some good tools in your dotfiles? Share it!</p>
<title type="html"><![CDATA[How to include a flowplayer video inside a fancybox modal window]]></title>
<link href=""/>
<content type="html"><![CDATA[<p>Thats how I make to integrate <a href="">flowplayer</a> inside a
<a href="">fancybox</a> modal window.</p>
<p>This following code shows a hidden <code>div</code> which will include the video. When
clicking the &#8220;Play video&#8221; link it will show a fancybox modal window with the
flowplayer video inside.</p>
<p>When closing the fancybox it will unload the video player and hide the div.</p>
<div><script src=''></script>
<noscript><pre><code>&lt;!-- Don't forget to include flowplayer js and fancybox js and css --&gt;
&lt;div style=&quot;width:665px;height:480px;display:none;&quot; id=&quot;player&quot;&gt;
&lt;a id=&quot;play-flv-video&quot; href=&quot;#player&quot;&gt;Play video&lt;/a&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
$(document).ready(function() {
'scrolling': false,
'titleShow': false,
'padding' : 0,
'onStart' : function() {
'onClosed' : function() {
<title type="html"><![CDATA[How to make Passenger 2.2.15 work with Bundler 0.8.1]]></title>
<link href=""/>
<content type="html"><![CDATA[<p><strong>Edit 2012-07-03:</strong> If you have the same problems&#8230; Try to switch to a better
solution like <a href="">Pow</a>.</p>
<p>From now I&#8217;m using Passenger with Apache and <a href="">Passenger Pane</a> in my development environment. The
only problem is that in most cases we&#8217;re using Bundler 0.8.1 in production,
which is old and deprecated. To keep my dev environment similar to the
production one I just use 0.8.1 in my dev machine.</p>
<p>To make them work together you just have to add the empty file
<code>config/setup_load_paths.rb</code> to your application. This file will be required
before Passenger loads you gems as an alternative way to loading those gems&#8230;
and it will just do nothing. You can get more info
<a href="">here</a>
Once this is done your application will just work :)</p>
<title type="html"><![CDATA[How to handle CMYK images with Paperclip]]></title>
<link href=""/>
<content type="html"><![CDATA[<p>In the last project I&#8217;ve worked I found myself reviewing the application again
and again on Internet Explorer since suddenly some images started showing a
beautiful &#8220;not-found-red-cross&#8221;.</p>
<p>After some research I found some blogs telling that Internet Explorer doesn&#8217;t
support images with a CMYK color scheme (<a href="">like this one</a>).</p>
<p>Since I&#8217;m using <a href="">Paperclip</a> to handle
the uploads to the application it wasn&#8217;t difficult to find a way to solve this.
That&#8217;s what I did:</p>
<div><script src=''></script>
<noscript><pre><code>class User &lt; ActiveRecord::Base
has_attached_file :avatar,
:styles =&gt; { :thumbnail =&gt; &quot;80x80&gt;&quot;, :normalized =&gt; &quot;100%&quot; },
:convert_options =&gt; { :all =&gt; '-strip -colorspace RGB'},
:default_style =&gt; :normalized
<p>As you can see I define a &#8220;normalized&#8221; style which doesn&#8217;t change geometry,
however it&#8217;s used to apply the color scheme conversion. Since it&#8217;s the default
style you can use it like <code>current_user.avatar.url</code> without worrying about the
<title type="html"><![CDATA[From Mac Ports to Homebrew]]></title>
<link href=""/>
<content type="html"><![CDATA[<p>I&#8217;ve lately moved from <a href="">Mac Ports</a> to
<a href="">Homebrew</a>. I find Homebrew an easier and more
intuitive system than Mac Ports and it gives me the option to customize the
<p>Homebrew is composed of a set of &#8220;formulas&#8221; with the instructions to compile
and install pieces of software, like ImageMagick or ffmpeg. Each one of these
formulas can be customized to make it suit your needs in an easy way. This is
an example formula from their web site.</p>
<div><script src=''></script>
<noscript><pre><code>require 'formula'
class Wget &lt; Formula
homepage ''
url ''
md5 '308a5476fc096a8a525d07279a6f6aa3'
def install
system &quot;./configure --prefix=#{prefix}&quot;
system 'make install'
<p>As you see, plain Ruby, easy to customize :)</p>
<p>To install it the first step for me was to remove Mac Ports, the <a href="">instructions are on its homepage</a>.
After this is quite easy to install Homebrew just following the instructions on
<a href="">it&#8217;s homepage</a>.</p>
<p>Once it&#8217;s done, you can install something as easy as.</p>
<p><code>brew install imagemagick</code></p>
<p>In fact I needed imagemagick just to <a href="">install rmagick</a> gem, which have this
library as a dependency.</p>
<title type="html"><![CDATA[Avoid using eval() on Javascript]]></title>
<link href=""/>
<content type="html"><![CDATA[<p>Javascript&#8217;s eval() function is evil. It&#8217;s performance is bad, and it&#8217;s very
difficult to debug. If you ever use it the <a href="">goto raptor</a>
will come for you&#8230;</p>
<p>OK, now I know why not to use <code>eval()</code> but&#8230; How could I avoid that evil
function in my code?</p>
<p>The 3 main uses I&#8217;ve found for <code>eval()</code> are:</p>
<li>Assign a property to an object when you have its name calculated in a
<li>Call a function when you&#8217;ve it&#8217;s name calculated in a variable</li>
<li>Create an object from a class when you&#8217;ve it&#8217;s name calculated in a variable</li>
<p>To sum up, <strong>do any access of any kind to any object&#8217;s property when you&#8217;ve this
property name in a variable</strong>. This kind of access can be accomplished using
this notation.</p>
<div><script src=''></script>
<noscript><pre><code>var property = &quot;property_name&quot;;
var object = new Object()
alert(object[property]) //will alert object.property_name
alert(object[&quot;property_name&quot;]); //will alert object.property_name
alert(window[&quot;object&quot;][&quot;property_name&quot;]) //will alert object.property_name</code></pre></noscript></div>
<p>If you don&#8217;t believe it, just copy&amp;paste the previous code on Firebug and see
how it works.</p>
<p>So, let&#8217;s now see an example on the previous cases</p>
<div><script src=''></script>
<noscript><pre><code>//assign a property to an object when
//you have its name calculated in a variable
var property_name = &quot;a_great_property&quot;
var object = new Object();
object[property_name] = &quot;Hello world!&quot;;
alert(object.property_name); //will alert Hello world!
//call a function when you’ve it’s name
//calculated in a variable
var function_name = &quot;whatever_function&quot;;
var object = {
whatever_function: function(){
alert(&quot;Hello world!&quot;);
object[function_name_](); // will alert Hello world!
//create an object from a class when
//you've it's name calculated in a variable
var klass_name = &quot;Object&quot;;
var object = new window[klass_name];
<p>Those were just a couple of basic examples that I could remember, but I&#8217;m quite
sure that there are much more other evil uses of <code>eval()</code> out there that you
can destroy :D</p>