Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Dennis Gu longkerdandy

🏠
Working from home
View GitHub Profile
@longkerdandy
longkerdandy / IdGenerator.java
Created Aug 24, 2017
Java code for generating Firebase Push IDs
View IdGenerator.java
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