Skip to content

Instantly share code, notes, and snippets.

# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
defmodule HappyNumbers do
def happy?(n) do
do_happy?(n, [])
end
defp do_happy?(1, _sequence), do: true
defp do_happy?(n, sequence) do
if Enum.member?(sequence, n) do
false
@gvc
gvc / gist:1594940
Created January 11, 2012 14:37
Weird RegExp
# Can anybody explain why this happens?
name = "John Doe"
name.gsub(/John/, "\\'")
# " Doe Doe"
@gvc
gvc / recibo.html.haml
Created May 13, 2011 01:05
View of a receit
#recibo.column.span-24
.column.span-16.prepend-4
%h1.titulo RECIBO
.column.span-4.last
%h2=number_to_currency @recibo.valor_total
.texto-recibo.column.span-24.last
%p
             
= "Recebi de #{@recibo.recebido_de}, a importância de #{number_to_currency @recibo.valor_total} "
@gvc
gvc / marcacao.rb
Created May 13, 2011 01:04
Class that represents a medical appointment
# encoding: utf-8
class Agendamento::Marcacao < Agendamento::Agendamento
belongs_to :procedimento, class_name: 'Agendamento::Procedimento'
belongs_to :convenio
belongs_to :paciente
belongs_to :atendimento
validates_presence_of :horario, :procedimento