Skip to content

Instantly share code, notes, and snippets.

View arthurfranca's full-sized avatar

arthurfranca

View GitHub Profile
module StringToBoolean
def to_bool
return true if self == true || self =~ (/^(true|t|yes|y|1)$/i)
return false if self == false || self.blank? || self =~ (/^(false|f|no|n|0)$/i)
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end
end
class String; include StringToBoolean; end
module BooleanToBoolean

Render and Redirect

The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.

Render

The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.

:action

@arthurfranca
arthurfranca / gist:5835835
Last active December 18, 2015 19:49
Erros
1) Failed to untar the box file. This is usually because you're attempting to add a box that isn't a valid box file. Please double check that the box file is properly packaged.
2) There was a problem with the configuration of Vagrant. The error message(s)
are printed below:
vm:
* Base MAC address for eth0/NAT must be set. Contact box maintainer for more information.
Hit Ctrl + Alt + F1
sudo apt-get update
sudo apt-get install linux-headers-generic
sudo apt-get dist-upgrade
--------------------
If your linux was not installed from a cd, but instead from a stick, do this:

Proposta

Você deverá criar um pequeno sistema georreferenciado para visualização e cadastramento de ocorrências policiais. Estas deverão ser categorizadas conforme indicação abaixo e receberão iconografia que permita ao Usuário distinguir visualmente sua natureza.

Interface Principal

A visão inicial do sistema oferecerá dois painéis: à direita, um mapa da cidade do Rio de Janeiro em nível de zoom que abranja todo o município; à esquerda, à guisa de sidebar, uma lista de ocorrências pertinentes à área de visualização atual.

À medida que o Usuário navegar pela interface de mapa, a lista à esquerda será atualizada para conter apenas as ocorrências na nova área de visualização (isto é, se mais próximo da escala mínima, um número menor de ocorrências surgirá; se mais afastado, maior.) Estas deverão ser ordenadas por sua data e hora de registro.

command emacs -> alt + x
diretorios -> ctrl + x, ctrl + f (ctrl + d para ver diretorios)
dividir janela -> ctrl + x + 2 (horizontal)
dividir janela -> ctrl + x + 3 (vertical)
sumir com divisoes de janela -> ctrl + x + 0
visualizar buffer -> ctrl + x + b
fechar buffer -> ctrl + w
navegar pelas janelas -> shift + setas
colorir sintaxe -> command ruby-mode
salvar -> ctrl + x + s