Skip to content

Instantly share code, notes, and snippets.

@efrenfuentes
efrenfuentes / bancos
Created October 11, 2019 13:42 — forked from xombra/bancos
Codigo y Bancos correspondientes de Venezuela
Banco:
<select name="banco">
<option value=""></option>
<option value="0156">100%BANCO</option>
<option value="0196">ABN AMRO BANK</option>
<option value="0172">BANCAMIGA BANCO MICROFINANCIERO, C.A.</option>
<option value="0171">BANCO ACTIVO BANCO COMERCIAL, C.A.</option>
<option value="0166">BANCO AGRICOLA</option>
<option value="0175">BANCO BICENTENARIO</option>
<option value="0128">BANCO CARONI, C.A. BANCO UNIVERSAL</option>

Authentication from Scratch with Rails 3.2.5

Rails 3.1 gives us a really easy way to authenticate users in our app: http_basic_authenticate_with. Using it, all we need to do is create a model for the user (certainly, User model :P) with an attribute called password_digest and some views feature for login and register users. After all, let's relax and let Rails do the hard work.

What we'll need

Gemfile

gem 'bcrypt-ruby', '~> 3.0.0'

Model

First at all, an User model which we can generate by following: rails g model user email:string password_digest:string and then add the following methodo call to generated class: has_secure_password

@efrenfuentes
efrenfuentes / numero_a_letras.rb
Created September 26, 2012 02:27
Numero a letras (Ruby)
module NumeroALetras
module Numeric
def self.included(recipiente)
recipiente.extend(ClassMethods)
recipiente.class_eval do
include InstanceMethods
end
end
end

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

@efrenfuentes
efrenfuentes / main.go
Created June 5, 2018 00:53 — forked from walm/main.go
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@efrenfuentes
efrenfuentes / md5-example.go
Created May 12, 2018 00:10 — forked from sergiotapia/md5-example.go
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@efrenfuentes
efrenfuentes / Spanish.inflectors.rb
Last active March 13, 2018 12:57 — forked from maxidr/Spanish.inflectors.txt
Spanish inflectors for rails 3
ActiveSupport::Inflector.inflections do |inflect|
inflect.plural /([aeiou])([A-Z]|_|$)/, '\1s\2'
inflect.plural /([rlnd])([A-Z]|_|$)/, '\1es\2'
inflect.plural /([aeiou])([A-Z]|_|$)([a-z]+)([rlnd])($)/, '\1s\2\3\4es\5'
inflect.plural /([rlnd])([A-Z]|_|$)([a-z]+)([aeiou])($)/, '\1es\2\3\4s\5'
inflect.singular /([aeiou])s([A-Z]|_|$)/, '\1\2'
inflect.singular /([rlnd])es([A-Z]|_|$)/, '\1\2'
inflect.singular /([aeiou])s([A-Z]|_)([a-z]+)([rlnd])es($)/, '\1\2\3\4\5'
inflect.singular /([rlnd])es([A-Z]|_)([a-z]+)([aeiou])s($)/, '\1\2\3\4\5'
ActiveSupport::Inflector.inflections do |inflect|
inflect.plural /([aeiou])([A-Z]|_|$)/, '\1s\2'
inflect.plural /([rlnd])([A-Z]|_|$)/, '\1es\2'
inflect.plural /([aeiou])([A-Z]|_|$)([a-z]+)([rlnd])($)/, '\1s\2\3\4es\5'
inflect.plural /([rlnd])([A-Z]|_|$)([a-z]+)([aeiou])($)/, '\1es\2\3\4s\5'
inflect.singular /([aeiou])s([A-Z]|_|$)/, '\1\2'
inflect.singular /([rlnd])es([A-Z]|_|$)/, '\1\2'
inflect.singular /([aeiou])s([A-Z]|_)([a-z]+)([rlnd])es($)/, '\1\2\3\4\5'
inflect.singular /([rlnd])es([A-Z]|_)([a-z]+)([aeiou])s($)/, '\1\2\3\4\5'
# download latest libevent2 and tmux sources, and extract them somewhere
#
# at the time of writing:
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# http://sourceforge.net/projects/tmux/files/latest/download?source=files
#
# don't compile tools as root, just don't do it.
# install deps
@efrenfuentes
efrenfuentes / install.sh
Created October 1, 2017 16:34 — forked from swelham/install.sh
Install Elixir on c9.io
sudo touch /etc/init.d/couchdb
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
sudo apt-get -y install elixir erlang-dev
rm erlang-solutions_1.0_all.deb