Skip to content

Instantly share code, notes, and snippets.

View klebervirgilio's full-sized avatar
🎯
Focusing

Kleber Correia klebervirgilio

🎯
Focusing
View GitHub Profile
class Array
def delete_first_occurence!(array=nil)
return nil if array.nil? || !array.is_a?(Array)
array.each do |item|
self.delete_at(self.index(item)) if self.index(item)
end
self
end
Hardware Overview:
Model Name: MacBook
Model Identifier: MacBook4,1
Processor Name: Intel Core 2 Duo
Processor Speed: 2.4 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache: 3 MB
Memory: 4 GB
Intel GMA X3100:
Chipset Model: GMA X3100
Type: GPU
Bus: Built-In
VRAM (Total): 144 MB
Vendor: Intel (0x8086)
Device ID: 0x2a02
Revision ID: 0x0003
Displays:
@klebervirgilio
klebervirgilio / install_postgis_osx.sh
Created July 31, 2011 00:25 — forked from juniorz/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@klebervirgilio
klebervirgilio / install_postgis_osx.sh
Created July 31, 2011 00:26 — forked from juniorz/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
Current:
* Clean Code
* Crafting Rails Applications
Next:
* Domain-driven Design
* Design Patterns in Ruby
class Array
def by(n)
buff, self_ = [], self.clone
if self.size % n == 0
(self.size/n).times{ buff << self_.shift(n) }
end
buff
end
@klebervirgilio
klebervirgilio / gist:2347905
Created April 10, 2012 02:02
Is it possible?
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -11,7 +11,11 @@ module ApplicationHelper
protected
#### :(
def link_href_for(item)
- item.top_level? and item.link_to_internal_route.present? ? item.link_to_internal_route : (item.page || item.url || '#')
"products_photos": [
{
"name": null,
"medium": {
"url": "/uploads/offers/75/offer_pictures/1/medium_foto__1_.JPG"
},
"small": {
"url": "/uploads/offers/75/offer_pictures/1/small_foto__1_.JPG"
},
var http = require('http'),
request = require('request');
x = '',
port = process.env.PORT || 8080;
http.createServer(function(req, response) {
http.get({
host: 'query.yahooapis.com',
path: "/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%27www.google.com%2Ffinance%2Fconverter%3Fa%3D1%26from%3DUSD%26to%3DBRL%27%20and%20xpath%3D%27%2F%2F*%5B%40id%3D" + '"currency_converter_result"' + "%5D%2Fspan%2Ftext()%27&format=json&callback="