Skip to content

Instantly share code, notes, and snippets.

View rqbazan's full-sized avatar
🦉
making things over the web

Ricardo Q. Bazan rqbazan

🦉
making things over the web
View GitHub Profile
@staltz
staltz / introrx.md
Last active June 6, 2024 03:19
The introduction to Reactive Programming you've been missing
@passsy
passsy / material text sizes.md
Last active May 25, 2023 04:24
Material font sizes
@ErikGartner
ErikGartner / .treehouse
Last active April 7, 2024 06:03
dTree Demo
1.3.1
@OrenBochman
OrenBochman / 01_enhanced_ecommerce_plugin.js
Last active July 5, 2023 18:39
Enhanced ecommerce snippets in universal analytics
//This command must occur after you create your tracker object and before you use any of the enhanced ecommerce specific functionality.
ga('require', 'ec');
@joen93
joen93 / RxErrorHandlingCallAdapterFactory.java
Created April 5, 2017 12:56
RxJava2 and Retrofit 2.2.0 compatible factory, which wraps the {@link RxJava2CallAdapterFactory} and takes care of the error conversion.
/**
* RxJava2 and Retrofit 2.2.0 compatible factory,
* which wraps the {@link RxJava2CallAdapterFactory} and takes care of the error conversion.
*
* Based on: https://github.com/square/retrofit/issues/1102#issuecomment-241250796
*/
public class RxErrorHandlingCallAdapterFactory extends CallAdapter.Factory {
private final RxJava2CallAdapterFactory mOriginalCallAdapterFactory;
private RxErrorHandlingCallAdapterFactory() {
@lucasscariot
lucasscariot / model-user.js
Last active June 22, 2023 17:08
Composite Primary Key in Sequelize
/*
* Migration
*/
'use strict';
module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.createTable('Users', {
firstName: {
type: Sequelize.STRING
},
@ziluvatar
ziluvatar / token-generator.js
Last active May 21, 2024 12:44
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@soulmachine
soulmachine / jwt-expiration.md
Last active June 5, 2024 21:41
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@tpraxl
tpraxl / ComponentWithResponsiveImage.js
Created December 28, 2017 18:22
React Native: Simple Responsive Image
// There are many complicated solutions out there.
// In fact, it's pretty easy to autoscale an image if you know the original dimensions.
// Otherwise, see Image.getSize. It should be easy to create a custom component that
// leverages Image.getSize to use this technique
//
import React, { Component } from 'react';
import { StyleSheet, Image, View } from 'react-native';
… // inside render()
<View style={styles.responsiveContainer}>
@bondvt04
bondvt04 / amqp.js
Last active September 20, 2022 02:01
RabbitMQ retries
'use strict';
const AmqpClient = require('amqplib');
const Promise = require('bluebird');
const contentTypeJson = 'application/json';
const contentEncoding = 'utf8';
const config = {
exchanges: [
{ name: 'A_COMMENT_CREATED', type: 'fanout' },
{ name: 'A_COMMENT_DELETED', type: 'fanout' },