Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

jesseonol jesster2k10

🏠
Working from home
  • Ireland
View GitHub Profile
View base_provider_spec.rb
require 'rails_helper'
RSpec.describe External::Provider::Base do
let(:subject) { described_class.new SecureRandom.hex }
describe '#for' do
it 'returns Facebook provider' do
class_instance = described_class.for :facebook
expect(class_instance).to eq(External::Provider::Facebook)
end
@jesster2k10
jesster2k10 / README.md
Last active Nov 17, 2020
Rails API Social Login
View README.md

Rails API-Only Social Login

This is another piece of code I've extrapolated from a Ruby on Rails project I'm currently working on. The code implmenets social login with a RoR API-based application, targeted at API clients.

The setup does not involve any browser-redirects or sessions as you would have to use working with Omniauth. Instead, what it does is takes an access_token generated on client-side SDKs, retireves user info from the access token and creates a new user and Identity in the database.

This setup works with native applications as described in the Google iOS Sign In Docs (see Authenticating with a backend server)

@jesster2k10
jesster2k10 / deviceSize.ts
Created Apr 13, 2020
React Native Device Size
View deviceSize.ts
import {Dimensions, Platform} from 'react-native'
const window = Dimensions.get('window')
const {width, height} = window
type DeviceSize =
| 'xsmall'
| 'small'
| 'normal'
| 'large'
@jesster2k10
jesster2k10 / README.md
Last active Nov 19, 2020
JWT Auth + Refresh Tokens in Rails
View README.md

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

@jesster2k10
jesster2k10 / Activity.ts
Last active Aug 3, 2019
Node.js Social Activity Stream
View Activity.ts
import {
Entity,
PrimaryGeneratedColumn,
Column,
ManyToOne,
BaseEntity,
} from 'typeorm'
import { Profile } from 'entities'
import { ActivityTargetType, ActivityVerb } from './enums'
@jesster2k10
jesster2k10 / Fade.tsx
Created Jul 4, 2019
React Native iOS 11 Style Large Title with Support For Search Component & Menu Buttons
View Fade.tsx
import React, { Component } from 'react'
import { Animated, StyleProp, ViewStyle } from 'react-native'
export type FadeDirection = 'up' | 'down'
interface FadeProps {
visible?: boolean
style?: StyleProp<ViewStyle>
children: React.ReactNode
direction?: FadeDirection
You can’t perform that action at this time.