Skip to content

Instantly share code, notes, and snippets.

View tigluiz's full-sized avatar

Tiago Luiz de Almeida tigluiz

View GitHub Profile
[-23.569945378311086, -46.705076102601495, -23.540999021688915, -46.6734984973985]
def distance(lat1, lon1, lat2, lon2)
radio = 6378137
dlat = (lat2-lat1) * Math::PI / 180
dlon = (lon2-lon1) * Math::PI / 180
a = Math::sin(dlat/2) * Math::sin(dlat/2) + Math::cos(lat1 * Math::PI / 180 ) * Math::cos(lat2 * Math::PI / 180 ) * Math::sin(dlon/2) * Math::sin(dlon/2)
c = 2 * Math::atan2(Math.sqrt(a), Math::sqrt(1-a))
d = radio * c;
# [dlat, dlon, a, c, d]
return "#{d.round(3)} km" if d > 1
class API::BaseController < ActionController::Metal
include AbstractController::Callbacks
include AbstractController::Rendering
include ActionView::Layouts
include ActionController::ImplicitRender
include ActionController::Helpers
include ActionController::UrlFor
include ActionController::Head
include ActionController::Renderers::All
include ActionController::MimeResponds
@tigluiz
tigluiz / .bash_profile
Last active December 11, 2015 06:08 — forked from victorhg/.bash_profile
export EDITOR=vim
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib/"
alias be="bundle exec"
alias ma="bundle exec rake db:migrate && bundle exec rake db:migrate RAILS_ENV=test"
alias mar="bundle exec rake db:rollback && bundle exec rake db:rollback RAILS_ENV=test"
alias assets="bundle exec rake assets:precompile"
alias assetss="bundle exec rake assets:precompile RAILS_ENV=staging"
alias ls="ls -G"
@tigluiz
tigluiz / pre commit hook
Created January 17, 2013 00:05
pre commit hook
#!/bin/bash
## START PRECOMMIT HOOK
files_modified=`git status --porcelain | egrep "^(A |M |R ).*" | awk ' { if ($3 == "->") print $4; else print $2 } '`
[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
## use ruby defined in project
source .rvmrc
for f in $files_modified; do
@tigluiz
tigluiz / Comando úteis
Created March 11, 2012 20:33
Comando úteis
brew search
brew search <nome ou parte do nome da biblioteca>
brew home <nome da biblioteca> - mostra a home da biblioteca
brew edit <nome da biblioteca> - mostra como irá ser instalado