Skip to content

Instantly share code, notes, and snippets.

View erikhoward's full-sized avatar

Erik Howard erikhoward

View GitHub Profile
@erikhoward
erikhoward / token.go
Created August 21, 2015 04:57
Go random token generator
package main
import (
"crypto/rand"
"encoding/base64"
"fmt"
)
func GenerateRandomBytes(n int) ([]byte, error) {
b := make([]byte, n)
@erikhoward
erikhoward / JavaPasswordSecurity.java
Created March 16, 2017 22:37 — forked from jtan189/JavaPasswordSecurity.java
Java PBKDF2 Password Hashing Code
import java.security.SecureRandom;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.SecretKeyFactory;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
/*
* PBKDF2 salted password hashing.
* Author: havoc AT defuse.ca
@erikhoward
erikhoward / encryption.java
Created March 29, 2017 20:24 — forked from itarato/encryption.java
Java AES CBC encryption example
package com.company;
import javax.crypto.Cipher;
import javax.crypto.Mac;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.MessageDigest;
import java.security.SecureRandom;
public class Main {
@erikhoward
erikhoward / netlify.toml
Created February 26, 2018 05:41
Hugo Netlify.toml
[build]
publish = "public"
command = "hugo"
[context.production.environment]
HUGO_VERSION = "0.36.1"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
[context.deploy-preview.environment]
@erikhoward
erikhoward / generate_ulid.sql
Created September 22, 2022 02:16 — forked from daspn-dock/generate_ulid.sql
PostgreSQL function to generate an unique ID of type ULID
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE OR REPLACE FUNCTION generate_ulid() RETURNS uuid
AS $$
SELECT (lpad(to_hex(floor(extract(epoch FROM clock_timestamp()) * 1000)::bigint), 12, '0') || encode(gen_random_bytes(10), 'hex'))::uuid;
$$ LANGUAGE SQL;
@erikhoward
erikhoward / fn_uuid_time_ordered.sql
Created September 25, 2022 18:24 — forked from fabiolimace/UUIDv6.sql
Function for generating time-ordered UUIDs (v6) on PostgreSQL
/**
* Returns a time-ordered UUID (v6).
*
* Tags: uuid guid uuid-generator guid-generator generator time order rfc4122 rfc-4122
*/
create or replace function fn_uuid_time_ordered() returns uuid as $$
declare
v_time timestamp with time zone:= null;
v_secs bigint := null;
@erikhoward
erikhoward / code-editor-rules.md
Created January 23, 2025 23:54 — forked from yifanzz/code-editor-rules.md
EP12 - The One File to Rule Them All

[Project Name]

Every time you choose to apply a rule(s), explicitly state the rule(s) in the output. You can abbreviate the rule description to a single word or phrase.

Project Context

[Brief description ]

  • [more description]
  • [more description]
  • [more description]