Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@DidiRaggio
DidiRaggio / keybase.md
Created February 26, 2017 22:42
keybase.md

Keybase proof

I hereby claim:

  • I am didiraggio on github.
  • I am didiraggio (https://keybase.io/didiraggio) on keybase.
  • I have a public key whose fingerprint is 6E7F 1E27 F2A5 4965 8365 1B2A F942 F64A 9C09 35BB

To claim this, I am signing this object:

@DidiRaggio
DidiRaggio / authenticable.rb
Created January 18, 2017 22:30
custom authentication
module Authenticable
# Devise methods overwrites
def current_user
@current_user ||= User.find_by(auth_token: request.headers['Authorization'])
end
def authenticate_with_token!
render json: { errors: "Not authenticated" },
status: :unauthorized unless user_signed_in?
@DidiRaggio
DidiRaggio / gist:174a143d647a4d47bc6fc7c28d5442ed
Last active August 2, 2016 23:10
Flattening an array, without using .flatten
a_hash = [[1,2,[3]],4]
flattenedArray = []
a_hash.each do |element|
if element.is_a?(Array)
element.each do |inner_element|
if inner_element.is_a?(Array)
inner_element.each do |third_layer_element|
flattenedArray.push(third_layer_element)
end