Skip to content

Instantly share code, notes, and snippets.

View longkerdandy's full-sized avatar
🏠
Working from home

Dennis Gu longkerdandy

🏠
Working from home
View GitHub Profile
@longkerdandy
longkerdandy / IdGenerator.java
Created August 24, 2017 09:18
Java code for generating Firebase Push IDs
package com.github.longkerdandy.matrix.backend.id;
import java.util.Random;
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
*
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other