Skip to content

Instantly share code, notes, and snippets.

View daydream05's full-sized avatar

Vince P. daydream05

View GitHub Profile
import _ from 'lodash'
import qs from 'qs'
// @see https://www.contentful.com/developers/docs/references/images-api/#/reference/resizing-&-cropping/specify-width-&-height
const CONTENTFUL_IMAGE_MAX_SIZE = 4000
const isImage = image =>
_.includes(
[`image/jpeg`, `image/jpg`, `image/png`, `image/webp`, `image/gif`],
_.get(image, `file.contentType`)
)
<Media query="(max-width: 550px)">
{matches =>
matches ? (
<CardCarousel>
{blogs.map((blog, index) => {
return (
<Link
key={index}
to={blog.node.fields.path}
>
class DeviseTokenAuthCreateUsers < ActiveRecord::Migration[5.1]
def change
create_table(:users) do |t|
## Required
######
# Truncated so i can show my example
######
## User Info
class User < ActiveRecord::Base
# Include default devise modules.
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :omniauthable
include DeviseTokenAuth::Concerns::User
end
class Api::V1::PhoneVerificationsController < ApplicationController
def start
response = Authy::PhoneVerification.start(via: "sms", country_code: 1, phone_number: phone_number_params)
if response.ok?
# verification was started
render json: {"success": true, message: "Verification code was sent to your phone number"}, status: :ok
else
render json: response
end
@daydream05
daydream05 / phone_verifications_controller.rb
Created January 11, 2018 23:56
don't use for production. for tutorial purposes only.
class Api::V1::PhoneVerificationsController < ApplicationController
def start
response = Authy::PhoneVerification.start(via: "sms", country_code: 1, phone_number: phone_number_params)
if response.ok?
# verification was started
render json: {"success": true, message: "Verification code was sent to your phone number"}, status: :ok
else
render json: response
end
# For phone verification
gem 'authy'
# gem for user authentication
gem 'devise_token_auth'
# needed for devise_token_auth to work
gem 'omniauth'