Skip to content

Instantly share code, notes, and snippets.

@kjmph
kjmph / A_UUID_v7_for_Postgres.sql
Last active November 6, 2024 19:57
Postgres PL/pgSQL function for UUID v7 and a bonus custom UUID v8 to support microsecond precision as well. Read more here: https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
create or replace function uuid_generate_v7()
returns uuid
as $$
begin
-- use random v4 uuid as starting point (which has the same variant we need)
-- then overlay timestamp
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
return encode(
[2020-02-09 16:41] [INFO] Welcome to Alacritty
[2020-02-09 16:41] [INFO] Configuration loaded from "/Users/kjmph/.config/alacritty/alacritty.yml"
[2020-02-09 16:41] [INFO] Device pixel ratio: 2
[2020-02-09 16:41] [INFO] Initializing glyph cache...
[2020-02-09 16:41] [INFO] ... finished initializing glyph cache in 0.033949313s
[2020-02-09 16:41] [INFO] Cell Size: 16 x 33
[2020-02-09 16:41] [INFO] Padding: 10 x 10
[2020-02-09 16:41] [INFO] Width: 1600, Height: 1200
[2020-02-09 16:41] [INFO] PTY Dimensions: Line(35) x Column(98)
[2020-02-09 16:41] [INFO] Initialisation complete
[2020-02-09 16:41] [INFO] Welcome to Alacritty
[2020-02-09 16:41] [INFO] Configuration loaded from "/Users/kjmph/.config/alacritty/alacritty.yml"
[2020-02-09 16:41] [INFO] Device pixel ratio: 2
[2020-02-09 16:41] [INFO] Initializing glyph cache...
[2020-02-09 16:41] [INFO] ... finished initializing glyph cache in 0.033949313s
[2020-02-09 16:41] [INFO] Cell Size: 16 x 33
[2020-02-09 16:41] [INFO] Padding: 10 x 10
[2020-02-09 16:41] [INFO] Width: 1600, Height: 1200
[2020-02-09 16:41] [INFO] PTY Dimensions: Line(35) x Column(98)
[2020-02-09 16:41] [INFO] Initialisation complete
@kjmph
kjmph / pig.rb
Last active August 29, 2015 14:08
require 'formula'
class Pig < Formula
homepage 'http://pig.apache.org/'
url 'http://www.apache.org/dyn/closer.cgi?path=pig/pig-0.13.0/pig-0.13.0.tar.gz'
sha256 'f4f6777165fcfc0d9df0a7ee4e897e0bdf73c8e8ec7fcc31db15c1917f5ca971'
patch :DATA
def install
@kjmph
kjmph / zunionstore_perf.patch
Created May 30, 2014 17:22
ZUNIONSTORE perf improvement
diff --git a/src/t_zset.c b/src/t_zset.c
index 4e946b4..658a932 100644
--- a/src/t_zset.c
+++ b/src/t_zset.c
@@ -1841,7 +1841,7 @@ inline static void zunionInterAggregate(double *target, double val, int aggregat
}
void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
- int i, j;
+ int i, j, k;
all: box2d.js
%.bc: %.cpp
python emscripten/tools/emmaken.py -I../ $< -o $@
box2d.bc: Collision/b2BroadPhase.bc Collision/b2CollideCircle.bc Collision/b2CollideEdge.bc Collision/b2CollidePolygon.bc Collision/b2Collision.bc Collision/b2Distance.bc Collision/b2DynamicTree.bc Collision/b2TimeOfImpact.bc Collision/Shapes/b2CircleShape.bc Collision/Shapes/b2EdgeShape.bc Collision/Shapes/b2ChainShape.bc Collision/Shapes/b2PolygonShape.bc Common/b2BlockAllocator.bc Common/b2Draw.bc Common/b2Math.bc Common/b2Settings.bc Common/b2StackAllocator.bc Common/b2Timer.bc Dynamics/b2Body.bc Dynamics/b2ContactManager.bc Dynamics/b2Fixture.bc Dynamics/b2Island.bc Dynamics/b2World.bc Dynamics/b2WorldCallbacks.bc Dynamics/Contacts/b2CircleContact.bc Dynamics/Contacts/b2Contact.bc Dynamics/Contacts/b2ContactSolver.bc Dynamics/Contacts/b2PolygonAndCircleContact.bc Dynamics/Contacts/b2EdgeAndCircleContact.bc Dynamics/Contacts/b2EdgeAndPolygonContact.bc Dynamics/Contacts/b2ChainAndCircleContact.bc Dynamics/Contacts/b2ChainAndPol