Skip to content

Instantly share code, notes, and snippets.

View henryhamon's full-sized avatar
🏠
Working from home

Henry Hamon henryhamon

🏠
Working from home
View GitHub Profile
class Cpf
def verifica_cpf(cpf = nil)
return false if cpf.nil?
if int_cpf(c[0.8], 1) != c[9] || int_cpf(c[0..9], 0) != c[10]
false
else
true
end
end

A Note

Forking has been fixed, but the old repositories will still be corrupted.

Basics

The method page will create a new page: page "home" do "Hello, world!"

require 'mechanize'
require 'hpricot'
class Orkut
def initialize(email, pass)
@agent = WWW::Mechanize.new
@email = email
@pass = pass
end
module ValidatesUrlFormatOf
IPv4_PART = /\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]/ # 0-255
REGEXP = %r{
\A
https?:// # http:// or https://
([^\s:@]+:[^\s:@]*@)? # optional username:pw@
( (xn--)?[^\W_]+([-.][^\W_]+)*\.[a-z]{2,6}\.? | # domain (including Punycode/IDN)...
#{IPv4_PART}(\.#{IPv4_PART}){3} ) # or IPv4
(:\d{1,5})? # optional port
([/?]\S*)? # optional /whatever or ?whatever
#!/bin/sh
# Run these five command lines:
# sudo sed 's/\#deb\(.*universe\)/deb\1/' /etc/apt/sources.list -i.bak
# apt-get update
# sudo apt-get install wget
# sudo wget http://gist.github.com/243432.txt -O kalango_server_setup.sh
# sudo sh kalango_server_setup.sh
# Check for proper permission
# ---------- example.rb ----------
#!/usr/bin/ruby
# Determine our parent pid
puts Process.pid
10.times do
puts "Before fork"
pid = fork do
# Realiza um PUT no servidor
def self.put(uri, content = {})
url = URI.parse(uri)
req = Net::HTTP::Put.new(uri)
req.basic_auth APP_CONFIG['email'], APP_CONFIG['password']
Net::HTTP.start(url.host, url.port) do |http|
req['Content-Type'] = 'text/plain; charset=utf-8'
req.set_form_data(content) unless content == {}
http.request(req)
end
<% @featured_products_groups.each do |featured_products_group| %>
<h5><%= featured_products_group.title.upcase %></h5>
<div class="show-case">
<% featured_products_group.featured_products.each_with_index do |featured_product, index| %>
<% product = featured_product.product %>
<% unless product.blank? %>
<div class="<%= index + 1 %>" data-color="<%= featured_products_group.color %>">
<%= link_to household_linen_product_path(product) do %>
<% if product.product_images.empty? %>
@henryhamon
henryhamon / phoenixc9.sh
Created August 15, 2016 12:52
shell to install Erlang, Elixir and Phoenix on C9.io
# For some reason, installing Elixir tries to remove this file
# and if it doesn't exist, Elixir won't install. So, we create it.
sudo touch /etc/init.d/couchdb
# Standard Ubuntu Elixir installation instructions
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
rm erlang-solutions_1.0_all.deb
sudo apt-get update
sudo apt-get update
sudo apt-get install -y ghc ghc-mod cabal-install wget
wget -q -O- https://s3.amazonaws.com/download.fpcomplete.com/ubuntu/fpco.key | sudo apt-key add -
echo 'deb http://download.fpcomplete.com/ubuntu/utopic stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
sudo apt-get update && sudo apt-get install stack -y
cabal update
stack update
rm -rf /var/lib/apt/lists/*