Skip to content

Instantly share code, notes, and snippets.

View yayoc's full-sized avatar
🌏
🚨🐠☄️🌈ॐ؞ৢ؞ؙؖ⁽⁾🧤🐠☄️˜ัิีึื์๎้็๋๊⦁ ☀️🐘ཫ་῍̩̖̬ ̎ ̎✧🌺ᕦ(;*Σ📊⏣ OO📼🍄●⦁   ●  ⦁  ●

yayoc yayoc

🌏
🚨🐠☄️🌈ॐ؞ৢ؞ؙؖ⁽⁾🧤🐠☄️˜ัิีึื์๎้็๋๊⦁ ☀️🐘ཫ་῍̩̖̬ ̎ ̎✧🌺ᕦ(;*Σ📊⏣ OO📼🍄●⦁   ●  ⦁  ●
View GitHub Profile
@soulmachine
soulmachine / jwt-expiration.md
Last active April 9, 2024 04:12
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:

@boneskull
boneskull / README.md
Last active April 10, 2024 12:47
example of how to debug mocha v4 if hanging

Here's an example of how to debug Mocha v4 if it hangs.

Ensure you're using a Node.js 8 or newer (or any version with async_hooks support).

If you run your test, you'll notice it hangs:

$ mocha test.js
@megamaddu
megamaddu / scroll-manager.js
Last active May 9, 2021 14:17
Scroll Manager for React Router v4
import React from 'react'
import { func, node, number, object, shape, string } from 'prop-types'
import { withRouter } from 'react-router'
import debounceFn from 'lodash/debounce'
class ScrollManager extends React.Component {
static propTypes = {
children: node.isRequired,
history: shape({
action: string.isRequired,
@gabro
gabro / validation.flow.js
Last active February 24, 2020 16:38
Dynamic object validation using $ObjMap in Flow
/* @flow */
// A simplified representation of types using phantom types (so that we store the Type information both at value and type level)
class Type<T> {};
class StringT extends Type<string> {}
class NumberT extends Type<number> {}
// A schema for a User
const User = {
name: new StringT(),
@paulirish
paulirish / what-forces-layout.md
Last active April 24, 2024 12:47
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@chrismdp
chrismdp / s3.sh
Last active March 5, 2024 12:57
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@sgronblo
sgronblo / Roman.hs
Last active January 7, 2024 18:23
Roman numeral parser in Haskell using Parsec
#!/usr/bin/env stack
-- stack --resolver lts-7.9 --install-ghc script --package QuickCheck --package either --package parsec
module Roman where
import Control.Applicative hiding ((<|>))
import Data.Either.Combinators
import Text.Parsec.Prim
import Text.Parsec.Combinator
import Text.Parsec.Error
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@suicide
suicide / artifactory-get.sh
Last active September 10, 2023 14:27
Downloads latest artifact version from artifactory
#!/bin/bash
# downloads latest version of an artifact from artifactory
set -e
usage(){
echo "Usage: $*" >&2
exit 64
}
@maxivak
maxivak / 00. tutorial.md
Last active April 12, 2024 05:42
Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler