This is a simple time-based nonce that you can used in various situations. The nonce is designed to be time-based so you can use it with a short lifetime (e.g. 5 or 10 seconds).
TimestampedNonce
uses 192 bits
with:
- First
64 bits
for the expiration timestamp, milliseconds since EPOCH. - The next
128 bits
is for entropy. This is secure enough in this situation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.atomic.*; | |
import java.util.concurrent.*; | |
import java.util.function.*; | |
import java.util.stream.*; | |
import java.util.*; | |
import cyclops.function.*; | |
/** | |
* This class is my attempt to see if I can make an implementation of cyclops's Memoize.memoizeSupplier | |
* simpler without relying on `synchronize` keyword (as the actual implementation), or `ConcurrentHashMap#computeIfAbsent` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"workflow": { | |
"title": "No Body Leaves", | |
"description": "Invite who ever leaves the channel again", | |
"icon": "", | |
"input_parameters": { | |
"Ft08U92KCRPH__user_id": { | |
"type": "slack#/types/user_id", | |
"name": "Ft08U92KCRPH__user_id", | |
"description": "The user who left the channel", |
This gist documents a tactic which works in a situation:
- Your Software System runs behind an AWS Application Load Balancer (ALB)
- Your Software System uses AWS WAF in conjunction with ALB.
- Your Software System handles Rate Limiting by itself.
- Your Software System Rate Limiting implementation make use of
X-Forwarded-For
header to determine the correct Client Source IP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.UUID; | |
import java.util.Base64; | |
import java.nio.ByteBuffer; | |
import java.nio.ByteOrder; | |
public class UuidShortener { | |
/* NOTE: | |
* The implementation was mostly copied from StackOverflow [1], | |
* as well as the hint of using BIG_ENDIAN [2]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DEPS org.openjdk.jmh:jmh-generator-annprocess:1.36 | |
// --javaagent=ap-loader@maxandersen=start,event=cpu,file=profile.html | |
package com.grokhard.benchmarking; | |
import org.openjdk.jmh.*; | |
import org.openjdk.jmh.annotations.*; | |
import org.openjdk.jmh.infra.Blackhole; | |
import java.util.stream.*; | |
import java.util.*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.util.stream.*; | |
import javax.naming.Context; | |
import javax.naming.NameNotFoundException; | |
import javax.naming.NamingEnumeration; | |
import javax.naming.NamingException; | |
import javax.naming.directory.Attribute; | |
import javax.naming.directory.Attributes; | |
import javax.naming.directory.DirContext; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.grokhard.explorejavaconcurrency; | |
import static java.util.concurrent.TimeUnit.SECONDS; | |
import java.util.Objects; | |
import java.util.concurrent.locks.Lock; | |
import java.util.concurrent.locks.ReadWriteLock; | |
import java.util.concurrent.locks.ReentrantReadWriteLock; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e -u -o pipefail | |
# Send, in sequential order, 10 requests and prints only the HTTP Status Code and the total time of the request | |
# with a Connnection Time Out in 5 seconds. | |
URL="$1" | |
{ | |
for _ in {1..10}; | |
do |
NewerOlder