Skip to content

Instantly share code, notes, and snippets.

View yungwarlock's full-sized avatar

Damian yungwarlock

View GitHub Profile
soulmachine /
Last active December 2, 2023 14:44
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:

laobubu /
Last active December 1, 2023 18:57
A very simple HTTP server in C, for Unix, using fork()

Pico HTTP Server in C

This is a very simple HTTP server for Unix, using fork(). It's very easy to use

How to use

  1. include header httpd.h
  2. write your route method, handling requests.
  3. call serve_forever("12913") to start serving on port 12913
piscisaureus /
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

tracker1 /
Last active November 24, 2023 23:52
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.


  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
yurydelendik / gist:f2b846dae7cb29c86d23
Last active November 2, 2023 12:09
PDF.js get/show hightlight
View gist:f2b846dae7cb29c86d23
function getHightlightCoords() {
var pageIndex = PDFViewerApplication.pdfViewer.currentPageNumber - 1;
var page = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
var pageRect = page.canvas.getClientRects()[0];
var selectionRects = window.getSelection().getRangeAt(0).getClientRects();
var viewport = page.viewport;
var selected = (r) {
return viewport.convertToPdfPoint(r.left - pageRect.x, - pageRect.y).concat(
viewport.convertToPdfPoint(r.right - pageRect.x, r.bottom - pageRect.y));
pylover /
Last active October 31, 2023 19:18
Fixing bluetooth stereo headphone/headset problem in ubuntu 16.04, 16.10 and also debian jessie, with bluez5.
#! /usr/bin/env python3
"""Fixing bluetooth stereo headphone/headset problem in debian distros.
Workaround for bug:
Run it with python3.5 or higher after pairing/connecting the bluetooth stereo headphone.
This will be only fixes the bluez5 problem mentioned above .
Licence: Freeware
tobiasraabe /
Last active October 31, 2023 16:33
Script to download files, resume downloads and validate downloads. Everything wrapped with a beautiful progressbar.
import click
import hashlib
import requests
from pathlib import Path
from tqdm import tqdm
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
estorgio / Mounting VirtualBox shared folders on Ubuntu Server 16.04
Last active October 31, 2023 13:25
Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS
View Mounting VirtualBox shared folders on Ubuntu Server 16.04

Update 28 July 2019: An updated version of this guide for Ubuntu Server 18.04 LTS is now available. Feel free to check it out.

Update 23 May 2020: This guide is ALREADY OUTDATED and might no longer work with new versions of Ubuntu and VirtualBox. Please consider switching to the updated guide instead. I will no longer respond to the replies to this gist. Thank you.

Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS

This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 16.04.3 LTS (Xenial Xerus)

coryodaniel / list.txt
Created May 13, 2020 22:04
GCP List of API Services
View list.txt
NAME TITLE Abusive Experience Report API Accelerated Mobile Pages (AMP) URL API Access Approval API Access Context Manager API Actions API Ad Exchange Buyer API Ad Exchange Buyer API II Ad Exchange Seller API Ad Experience Report API