Skip to content

Instantly share code, notes, and snippets.

@ygotthilf
ygotthilf / jwtRS256.sh
Last active April 11, 2024 07:44
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@ygotthilf
ygotthilf / scrap.js
Last active September 8, 2015 16:25
Quick scrapper for list/detail website
var _ = require('lodash');
var request = require('request');
var cheerio = require('cheerio');
var iconv = require('iconv-lite');
var moment = require('moment');
var headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
};
@ygotthilf
ygotthilf / authRouting.run.js
Last active August 29, 2015 14:28
AngularJS 1.x : Route access restriction
// module is your angular module
module.run(authRouting);
/* @ngInject */
function authRouting($state, $rootScope, $urlRouter, Auth) {
$rootScope.$on('$stateChangeStart', function(event, toState) {
var requireAuth;
if (toState.data) {
requireAuth = toState.data.requireAuth; // PROPERTY TO SET FOR ROUTE ACCESS RESTRICTION
@ygotthilf
ygotthilf / authInterceptorConfig.config.js
Last active August 13, 2020 19:25
AngularJS 1.x : send JWT and expired refresh token
// module is your angular module
module.config(authInterceptorConfig);
/* @ngInject*/
function authInterceptorConfig($httpProvider) {
$httpProvider.interceptors.push('authInterceptor');
}
module.factory('authInterceptor', authInterceptor);
@ygotthilf
ygotthilf / module.js
Last active August 29, 2015 14:19
A module pattern that works on Browser, Node.js, Web Workers, ...
/**
* MyModule is a module that works on Browser, Node.js, Web Workers, ...
*/
(function(global) {
'use strict';
// Define your MyModule here
global.MyModule = (global.module || {}).exports = MyModule;