Skip to content

Instantly share code, notes, and snippets.

View gobhi's full-sized avatar

Gobhi Theivendran gobhi

View GitHub Profile
@gobhi
gobhi / README.md
Created June 19, 2024 22:56 — 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:

@gobhi
gobhi / axios-catch-error.js
Created August 7, 2020 09:49 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@gobhi
gobhi / ree.sh
Created August 28, 2012 20:23 — forked from andreimaxim/ree.sh
REE 1.8.7 on Mountain Lion
# Thanks Olly Smith! http://coderwall.com/p/fywjrw
brew tap homebrew/dupes
brew install apple-gcc42
# Requires XQuartz from http://xquartz.macosforge.org/landing/
CPPFLAGS=-I/opt/X11/include CC=/usr/local/bin/gcc-4.2 rbenv install ree-1.8.7-2012.02
@gobhi
gobhi / rvm2rbenv.txt
Created August 28, 2012 17:26 — forked from brentertz/rvm2rbenv.txt
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@gobhi
gobhi / app.js
Created August 12, 2012 01:31 — forked from maletor/app.js
Bootstrap data using RequireJS and Backbone
require(['userAttributes', 'backbone', 'user_router'], function (config, Backbone, UserRouter) {
var userRouter = new UserRouter() {
userAttributes: userAttributes
};
return router;
});
@gobhi
gobhi / app.js
Created July 29, 2012 16:25
Bootstrap data using RequireJS and Backbone
require(['config', 'backbone', 'router'], function (config, Backbone, Router) {
var router = new Router() {
config: config
};
return router;
});