Implements a method that flattens a nested array, based on recursion.
Includes several tests that check the method behavior with different arrays.
Custom recipe to get OS X 10.10 Yosemite running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.
This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.
You are encouraged to fork this and modify it to your heart's content to match your own needs.
Mecanismo usado por Devise identificar un usuario por medio de un token para confirmar el email: Siguiendo este issue, vemos cómo podemos generar un token para la transacción. El código
Devise.token_generator.generate(class, column)
genera un token encriptado único para una instancia de la clase class
y devuelve el token encriptado y sin encriptar. El token sin encriptar se envía en el link del email. Al acceder a este link, Devise comprobará qué instancia de Order
contiene un token encriptado correspondiente al token del link así:
def generate_confirmation_token
raw, enc = Devise.token_generator.generate(self.class, :confirmation_token)
First of all: Im folliwing this tutorial from Rails Casts to do the implementation of facebook:
Creating the application: rails new facebook_oauth
Moving to the directory: cd facebook_oauth
Add the omniauth gem to your Gemfile: gem ‘omniauth’
In your terminal, run bundle
Create the file config/initializers/omniauth.rb
and add:
def calculator string | |
while string.match /[*\/]/ | |
# p string | |
string.gsub!(/(\d+)\s*([*\/])\s*(\d+)/) do |regex| | |
num1 = $1.to_i | |
num2 = $3.to_i | |
operator = $2.to_sym | |
"#{[num1, num2].reduce(operator)}" | |
end | |
end |
###Turbolinks and Javascrit
You might have some weird behavior in your rails app if you use Turbolinks and then you write some Javascript code without considerig the way Turbolinks actually works.
If you expect your Javascript code to run inside of $(document).ready()
, you will notice that it doesn't always happen. Your code will run maybe the first time you load the page in the browser, but not the subsequent times. Maybe won't run also when you access a page by clicking on a link (but then it will work when you refresh your page).
Using Turbolnks, when you click on a link, your web browswer won't send a request to the server in order to get the content. Instead, it will replace the content of the with the parsed result of an ajax request to the link. This way, all the code that you wrote under
$(document).ready(function(){
// some more code
})
$(function(){ | |
$("#target").submit(function(event){ | |
event.preventDefault(); | |
email = $("input[name='email']").val(); | |
password = $("input[name='password']").val(); | |
$('li').remove(); | |
if (password.match(/\w{8}/) == null){ | |
$("#errors").append("<li>Password must be at least 8 characters</li>"); |
$(function(){ | |
// Your code goes here... | |
$('#previous_frame').click(function(){ | |
// this.preventDefault(); | |
$('.frames').animate({left: "-=360"}, 500); | |
console.log("Hi hello"); | |
}); | |
$('#next_frame').click(function(){ | |
// this.preventDefault(); |
//------------------------------------------------------------------------------------------------------------------ | |
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here. | |
//------------------------------------------------------------------------------------------------------------------ | |
function Animal (name, feet) | |
{ | |
this.name = name; | |
this.feet = feet; | |
// this wasn't passing the last test, |
<!doctype html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css"> | |
<link rel="stylesheet" href="main.css"> | |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800"> | |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900"> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css"> | |
</head> |