A Pen by Marcus Obst on CodePen.
defmodule MyApp do | |
use Application | |
def start(_type, _args) do | |
import Supervisor.Spec, warn: false | |
children = [ | |
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [ | |
dispatch: dispatch | |
]) |
# Greatest common divisor of 1 or more numbers. | |
from functools import reduce | |
def gcd(*numbers): | |
""" | |
Return the greatest common divisor of 1 or more integers | |
Examples | |
-------- |
#!/bin/bash | |
set -e | |
CURRENT_NAME="Zauberantrag" | |
CURRENT_OTP="zauberantrag" | |
NEW_NAME="Wunderantrag" | |
NEW_OTP="wunderantrag" |
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> |
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.
gem 'bcrypt-ruby', '~> 3.0.0'
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
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:
package main | |
import ( | |
"fmt" | |
"log" | |
"strconv" | |
"github.com/miekg/dns" | |
) |
import ( | |
"crypto/md5" | |
"encoding/hex" | |
) | |
func GetMD5Hash(text string) string { | |
hasher := md5.New() | |
hasher.Write([]byte(text)) | |
return hex.EncodeToString(hasher.Sum(nil)) | |
} |