Installing Ruby 2.0.0-p0 on OSX

izzy's playlists!

Discoholic 🪩
Fai_Ryy
Sweet Seals For You, Always
Interview Vampire Daily

❣ Chile in a Photography ❣
Noah Kahan
Lint Roller? I Barely Know Her
Aqua Utopia|海の底で記憶を紡ぐ
ojovivo
h

pixel skylines
Keni
RMH
No title available
Cosmic Funnies
Cosimo Galluzzi
todays bird

roma★

Game Changer & Make Some Noise

seen from United States
seen from Bangladesh

seen from Germany
seen from Netherlands
seen from Georgia

seen from Türkiye
seen from Switzerland

seen from Indonesia
seen from Uzbekistan
seen from United States
seen from France

seen from Palestinian Territories
seen from Brazil
seen from United States
seen from Netherlands

seen from United Kingdom
seen from Bangladesh
seen from Lebanon
seen from Canada
seen from Pakistan
@lucasallanamorim
Installing Ruby 2.0.0-p0 on OSX
JRuby 1.7.2 Released
I'm big fan of JRuby. The Ruby language's flexibility with the JVM's power give to us a big weapon to create amazing applications.
http://www.jruby.org/2013/01/04/jruby-1-7-2.html
Excellent talk about Refactoring
I have to say that this one was the best talk about refactoring that I ever watch. I highly recommend it.
Rack 1.4.1 error when a parameter's key is nil
While we are waiting for the next release of rack that will come with that fix, I extracted the code fix from the pull request in rack repository and created a monkey patch to fix this problem.
This problem often happens when you are using google analytics.
https://gist.github.com/2896202
Representable Resources
Last weekend I created a new rubygem to help to build a good api to your application. With this gem you can separate your models and business logics of your representable resource. At the github has information about how to use it https://github.com/lucasallan/representable_resources
ruby wrapper to access google movies informations
Hello everyone, I just released a new rubygem to access google movies information. Unfortunately google doest not provide a api interface to access this information. so my gem get the html and use nokogiri to parser it and get the information. I hope it can be useful for someone. It was fun to working on it and learning more about nokogiri. https://github.com/lucasallan/google_movies
Migrating from Wordpress to Tumblr
Hello guys,
After too many problems with wordpress, I'm migrating my blog to tumblr. This process can take a while because I'm in a very full week in my job.
Thanks,
Lucas
If you're still using ruby-debug, you're doing life wrong.
First, I'm not here to talk bad things about ruby-debug. For almost all my career as ruby developer I have been using ruby-debug and it works well. But since I discovered pry my life as ruby developer is more easy. I really recommend you check it out, you probably will love it. I don't go talk to much about pry, there is to many documentation out there. To know more about ruby debug and pry, I strongly recommend you to watch Mastering the ruby debugger by Jim Weirich.
By the way: this post title is based on If you're using Node.js, you're doing life wrong.
Books
Hi guys, I took this month to read some books that I wanna read for a long time. I created a gist to share which books I'm reading and I'm accepting more suggestions about another books. So I created a goal to read at least 2 books a month, maybe more. In this month I'm reading Clean Code and Crafting Rails Applications. In a few weeks I will write a review about this books.
Generate PDF with prawn and Google charts
Hey guys, It's a quickly post about how to generate pdf with prawn and google charts. Prawn is a awesome lib in ruby for generating PDF documents and google charts is a API to generate charts. I like to create a class responsible to generate my pdf documents. Here is my implementation:
It's a simple ruby code, very easy to understand (I guess). In the next post I will show you how to send this report to client using Rails.
OmniAuth strategy for authenticating to Podio
Hello fellows, Now that I finished my bachelor's degree, I have free time to devote to open source projects that I like and a project that I really like is OmniAuth. OmniAuth is a libary that standardizes multi-provider authentication for web applications. It's very flexible and nice! In my current job, we are using a lot a web application called Podio. It's a very cool app. So yesterday I started to develop a OmniAuth strategy for authenticating to Podio and today I finished it. You can see the code here Fell free to contribute and use it. Thanks,
Creating custom middlewares with Rack
To kick off, What is Rack? A Rack applications is a object that has a methods named 'call' and that method receive the enviroment as a argument and return a array with exactly three values: status, header and body. The following is a simple example:
class App def call(env) [200, {"Content-Type" => "text/plain"},["LucasAllan.com"]] end end
Rack is the base of a lot of web frameworks written in Ruby, like Ruby On Rails, Sinatra, Camping and others... What is a Rack Middleware? Rack middleware is a kind of filter to requests in a Rack application. It behaves like a rack application and needs the same things that a simple rack application. It's like a rack application inside another rack application. I created a file named cache_control.rb with the follow code:
require 'rack/utils' module Rack class CacheControl include Rack::Utils def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) headers = Utils::HeaderHash.new(headers) headers['Cache-Control'] = "no-cache" [status, headers, body] end end end
In that code, I get the enviroment (with headers, content and http code) and I can manipulate it. In that case I just added a new header. Now in my Rack Application I will load that middleware and use it.
require 'rack' require 'cache_control' class App def call(env) [200, {"Content-Type" => "text/plain"},["LucasAllan.com"]] end end use Rack::CacheControl run MyApp.new
I used the word 'use' to call my middleware. You can run this app using the Thin server, for this you must have the Thin installed: gem install thin And use the follow command: You the file name of your application is config.ru (Rack standard), use it: thin -R config.ru start If don't, replace config.ru for the right filename. You can try to access the application using your browser or curl: curl -i localhost:3000 HTTP/1.1 200 OK Content-Type: text/plain Cache-Control: no-cache Connection: close Server: thin 1.3.1 codename Triple Espresso LucasAllan.com
Integrations tests and Devise Login
Yesterday I started doing a new project using devise gem to manage login features. When I started to do integration tests using rspec, I found a problem: devise test helpers don't work with rspec integration test. So this is a quick solution to fix it.
At top of spec file, after require ‘spec_helper’ include Warden::Test::Helpers. And in the before(:each) block I just used a warden helper to do login.
PostgreSQL and Postgis on Mac OS Lion
Recently I had some problems with Mac OS Lion and I decided to do a clean install. So all went well until I decided to install PostgreSQL with spatial extension called postgis and so the problems began. My friend Kleber gave me a Gist with some simple steps to install postgresql and postgis after Lion update. So I was trying to follow those steps but it's didn't work. So I searched for solutions and added in that new Gist.
Singleton Classes on Ruby
First, this post is not about Singleton Pattern. Every object on Ruby belongs to two classes. The class that instantiated it and one anonymous class. This anonymous class is named Singleton Class. We can access the Singleton class using something like that:
class << my_class end
In that example, my_class is the Singleton Class that I want. So we can add a new method using something like that:
class City class << self def size @size ||= 0 end end end
Every time that we add method in a object, is added like a singleton method and it's added only in the specific object that it was defined. For example:
city = "Vancouver" another_city = "Montreal" def city.province "British Columbia" end city.province #=> "British Columbia" another_city.respond_to?(:province) #=> false
This is a simple example of the power of Ruby. In the next post I will show you some other cool things that you can do with Ruby.
will_paginate with Rails3 and Caching
This is a quick solution to use will_paginate gem with Rails3 and Caching. If you have a Rails application with cache and you are using will_paginate gem, maybe you have a problem with your routes. A simple solution for this, is add a route in your routes.rb file. For example, if you have a model named 'post' and you need add paginate in your index page. You have a problem, because for default your url with paginate is '/posts?page=number' and this doesn't work because your cache ignore the page parameter when it saves. So the solution is change the routes for use some like this '/posts/page/number'. In your routes.rb add:
resources :posts, :except => :index get "posts(/pages/:page)" => "posts#index", :as => :posts
Just it! Now your application will work with page caching and paginate.
Rails 2.3.10 on App Engine
Durante esse feriado de natal, estive testando o suporte a JRuby no Google App Engine. Conseguir rodar tanto uma aplicação feita com Sinatra quanto uma feita em Rails 2.3.10. Infelizmente a gem google-appengine ainda não suporta o Rails 3, mas esse suporte já está sendo desenvolvido. Então pesquisando no Github achei um gist mostrando como gerar uma aplicação com Rails 2.3.10 e DataMapper, infelizmente não funcionou como deveria. Mas ao analisar percebi que o problema era não está incluindo o DataMapper::Resource no model, então fiz um fork do gist e modifiquei, testei e agora tudo está funcionando. Para acessar o gist clique aqui e divirta-se.