Skip to content

Instantly share code, notes, and snippets.

@jeanpaulsio
jeanpaulsio / README.md
Created February 8, 2021 00:49 — forked from jesster2k10/README.md
JWT Auth + Refresh Tokens in Rails

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:

" UI
syntax on
highlight Normal ctermbg=None
set guifont=OperatorMono-Book:h16
" Fix cursor display in cygwin
if has("win32unix")
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
@jeanpaulsio
jeanpaulsio / postgres-brew.md
Created September 8, 2018 21:19 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
class App extends React.Component {
state = { showError: true }
toggleError = () => {
this.setState((prevState, props) => {
return { showError: !prevState.showError }
})
};
render() {
const DivWithErrorHandling = withErrorHandling(({children}) => <div>{children}</div>)
const withErrorHandling = WrappedComponent => ({ showError, children }) => {
return (
<WrappedComponent>
{showError && <div className="error-message">Oops! Something went wrong!</div>}
{children}
</WrappedComponent>
);
};
@jeanpaulsio
jeanpaulsio / conditional_rendering.js
Created December 13, 2017 04:59
Conditional Rendering in React
render () {
return (
<div>
{this.props.errors && <div>Error Message</div>}
<h1>Your Amazing Content</h1>
</div>
);
}
@jeanpaulsio
jeanpaulsio / schedule.js
Created August 26, 2017 22:33
Time Data Structure
/*
0 - Sunday
1 - Monday
2 - Tuesday
3 - Wednesday
4 - Thursday
5 - Friday
6 - Saturday
@jeanpaulsio
jeanpaulsio / index.html
Created August 21, 2017 23:42
Appending List Items
<script type="text/javascript">
window.onload=function() {
var el = document.getElementById('postComment').addEventListener('click', registerClickHandler);
function registerClickHandler() {
var inputValue = document.getElementById('comment').value;
var list = document.getElementById('commentList');
if (inputValue) {
var listNode = document.createElement("LI");
@jeanpaulsio
jeanpaulsio / email_helper.js
Created July 28, 2017 22:58
Algorithm for Sorting Duplicate Items
export const filterEmails = emails => {
let resultsMap = {};
let results = []
for (let i = 0; i < emails.length; i++) {
let email = emails[i].toLowerCase();
if (!resultsMap[email]) {
resultsMap[email] = true
results.push(email)