Skip to content

Instantly share code, notes, and snippets.

View mangar's full-sized avatar
:octocat:
Working from home

Marcio Mangar mangar

:octocat:
Working from home
View GitHub Profile
@mangar
mangar / Googl.rb
Last active October 7, 2015 13:28
Cria URLs curtas com o goo.gl
#
# Documentation and How to generate the API Key: https://developers.google.com/url-shortener/v1/getting_started
#
module Utils
class Googl
END_POINT = "https://www.googleapis.com/urlshortener/v1/url?key=YOUT_KEY_HERE"
#
# Cria uma Short URL utilizando o servido do Google: goo.gl
@mangar
mangar / gist:3153747
Created July 20, 2012 22:53
Cria o formato amigávem de postagem: "Publicado há X tempos atrás"
#
# Cria a data de publicacao no formato 'há XX YY atrás
#
def created_at_tempos_atras
agora = Time.now
dif = (agora - self.created_at).to_i
if dif < 60
dif = "#{dif} segundos"
elsif dif > 59 && dif < 120