Skip to content

Instantly share code, notes, and snippets.

@coverboy
coverboy / jwt-expiration.md
Created Apr 10, 2022 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?
View jwt-expiration.md

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:

@coverboy
coverboy / gist:36bde6ad5a8c19d402dda8a4a5fa9674
Created Feb 5, 2022
javascript function execution time
View gist:36bde6ad5a8c19d402dda8a4a5fa9674
const time_start = new Date().getTime();
// some function
const time_end = new Date().getTime();
console.log(`search elapsed time ==> ${(time_end - time_start) / 1000}s`);
@coverboy
coverboy / Dockerfile
Last active Jul 24, 2021
Jenkins as a Docker Container (Agent Role)
View Dockerfile
# Explanation : https://blog.1234.co.kr/2021/07/24/jenkins-as-a-docker-container-agent-role/
FROM ubuntu:20.04
# First off, replace ubuntu repository for fast download.
# Check the official ubuntu repository mirror site
# https://launchpad.net/ubuntu/+archivemirrors
RUN sed --in-place 's/archive.ubuntu.com/mirror.kakao.com/g' /etc/apt/sources.list
RUN apt update && apt upgrade -y
@coverboy
coverboy / formatter-annotation.java
Created Feb 16, 2021 — forked from vanpeerdevelopment/formatter-annotation.java
Example of the use of the @Formatter:off and @Formatter:on annotations in eclipse to disable formatting for a piece of code.
View formatter-annotation.java
public class Formatter {
/**
* The next piece of code is not formatted
* because of the @formatter annotations.
*/
// @formatter:off
public void nonFormattedMethod() {
int sum = 1 + 2 + 3 + 4 + 5;
}
@coverboy
coverboy / reflect.py
Created Jan 23, 2021 — forked from huyng/reflect.py
A simple echo server to inspect http web requests
View reflect.py
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@coverboy
coverboy / LoggingController.java
Created Sep 6, 2020
spring boot logging level
View LoggingController.java
log.trace("A Trace msg");
log.debug("A Debug msg");
log.info("An Info msg");
log.warn("A Warn msg");
log.error("An Error msg");
@coverboy
coverboy / intellij-java-google-style.xml
Last active Dec 19, 2020
intellij-java-google-style.xml
View intellij-java-google-style.xml
<?xml version="1.0" encoding="UTF-8"?>
<code_scheme name="GoogleStyle_SK">
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="4" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="4" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="false" />
<option name="LABEL_INDENT_SIZE" value="0" />
@coverboy
coverboy / curl.md
Created Mar 5, 2019 — forked from subfuzion/curl.md
curl POST examples
View curl.md

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@coverboy
coverboy / app.js
Created Oct 21, 2018 — forked from sogko/app.js
gulp + expressjs + nodemon + browser-sync
View app.js
'use strict';
// simple express server
var express = require('express');
var app = express();
var router = express.Router();
app.use(express.static('public'));
app.get('/', function(req, res) {
res.sendfile('./public/index.html');
@coverboy
coverboy / README.md
Created Aug 3, 2018 — forked from MarkTiedemann/README.md
An Easier Way to Enforce Required Parameters in ES6
View README.md

An Easier Way to Enforce Required Parameters in ES6

Expands on Handling required parameters in ECMAScript 6 by Axel Rauschmayer.

The idea (which is credited to Allen Wirfs-Brock) is, in essence, to use default parameter values to call a function which throws an Error if the parameter is missing:

const throwIfMissing () => { throw new Error('Missing parameter') }