Skip to content

Instantly share code, notes, and snippets.

View juandefelix's full-sized avatar

Juan Ortiz juandefelix

View GitHub Profile
juandefelix /
Last active June 15, 2016 04:21
Implements a method that flattens a nested array, based on recursion.


Implements a method that flattens a nested array, based on recursion.
Includes several tests that check the method behavior with different arrays.

juandefelix /
Created March 4, 2016 22:19 — forked from kevinelliott/
Mac OS X 10.10 Yosemite Setup

Mac OS X 10.10 Yosemite

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.

Install Software

juandefelix /
Last active January 24, 2016 03:50
Devise email confirmation token generation

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)
juandefelix /
Last active February 6, 2024 22:44
Adding Facebook Login to a Rails application

Configuring a Rails app to use facebook sign in###

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:

juandefelix / string_calculator.rb
Last active August 29, 2015 14:02
Calculator. This method calculates the result of the basic mathematical operations in a string
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)}"
juandefelix / form-validator.js
Last active March 5, 2020 03:32 — forked from ksolo/form-validator.js
Form Validation
email = $("input[name='email']").val();
password = $("input[name='password']").val();
if (password.match(/\w{8}/) == null){
$("#errors").append("<li>Password must be at least 8 characters</li>");
juandefelix / carousel.js
Last active August 29, 2015 13:56 — forked from ksolo/carousel.js
Image Carousel
juandefelix / zoo.js
Last active August 29, 2015 13:56 — forked from dbc-challenges/zoo.js
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
function Animal (name, feet)
{ = name;
this.feet = feet;
// this wasn't passing the last test,
juandefelix / index.html
Last active August 29, 2015 13:56 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<link rel="stylesheet" href="">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href=",400,600,700,800">
<link rel="stylesheet" href=",900">
<link rel="stylesheet" href="">