Skip to content

Instantly share code, notes, and snippets.

View rozgo's full-sized avatar

Alex Rozgo rozgo

View GitHub Profile
@rozgo
rozgo / accounting.sql
Created August 19, 2022 19:37 — forked from NYKevin/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...
@rozgo
rozgo / wgsl_3d_sdf.md
Last active September 9, 2022 02:04 — forked from munrocket/wgsl_3d_sdf.md
3D SDF Primitives in WGSL

3D SDF Primitives in WGSL

How to use this gist:

  1. Build a sphere tracer with WebGPU (paper, paper2, youtube)
  2. Create model with sdf functions from here
  3. Add light and shadows
  4. ???
  5. PROFIT

This code tested in Chrome and Firefox, should work on PC too.

@rozgo
rozgo / postgres.md
Created February 25, 2022 00:03 — forked from jcoleman/blog.md

Braintree Payments uses PostgreSQL as its primary datastore. We rely heavily on the data safety and consistency guarantees a traditional relational database offers us, but these guarantees come with certain operational difficulties. To make things even more interesting, we allow zero scheduled functional downtime for our main payments processing services.

Several years ago we published a blog post detailing some of the things we had learned about how to safely run DDL operations without interrupting our production API traffic.

Since that time PostgreSQL has gone through quite a few major upgrade cycles -- several of which have added improved support for concurrent DDL. We've also further refined our processes. Given how much has changed, we figured it was time for a blog post redux.

In this post we'll address the following topics:

@rozgo
rozgo / README.md
Created January 20, 2021 06:38 — forked from corenel/README.md
Install NVDEC and NVENC as GStreamer plugins

Install NVDEC and NVENC as GStreamer plugins

Environment

  • Ubuntu 18.04
  • NVIDIA driver 430.40
  • NVIDIA Video Codec SDK 9.0.20

Steps

@rozgo
rozgo / Event-stream based GraphQL subscriptions.md
Created January 14, 2021 20:08 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@rozgo
rozgo / rust1plus1.md
Created October 13, 2020 00:40
Proving that 1 + 1 = 2 in Rust

Proving that 1 + 1 = 2 in Rust

The fact that 1 + 1 is equal to 2 is one of those things that is so obvious it may be hard to justify why. Fortunately mathematicians have devised a way of formalizing arithmetic and subsequently proving that 1 + 1 = 2. Natural numbers are based on the Peano axioms. They are a set of simple rules that define (along with a formal system) what natural numbers are. So in order to prove 1 + 1 = 2 in Rust we first need a formal system capable of handling logic. The formal system that we'll be using is not some random crate, but Rust's type system itself! We will not have any runtime code, instead the type checker will do all the work for us.

Implementing the Peano axioms

First let's go trough the Peano axioms. The first axiom is that "Zero is a natural number". Basically what it says is that zero exists. In order to express that in the type system, we just write:

@rozgo
rozgo / imgui_node_graph_test.cpp
Created March 4, 2020 19:19 — forked from ocornut/imgui_node_graph_test.cpp
Node graph editor basic demo for ImGui
// Creating a node graph editor for ImGui
// Quick demo, not production code! This is more of a demo of how to use ImGui to create custom stuff.
// Better version by @daniel_collin here https://gist.github.com/emoon/b8ff4b4ce4f1b43e79f2
// See https://github.com/ocornut/imgui/issues/306
// v0.03: fixed grid offset issue, inverted sign of 'scrolling'
// Animated gif: https://cloud.githubusercontent.com/assets/8225057/9472357/c0263c04-4b4c-11e5-9fdf-2cd4f33f6582.gif
#include <math.h> // fmodf
// NB: You can use math functions/operators on ImVec2 if you #define IMGUI_DEFINE_MATH_OPERATORS and #include "imgui_internal.h"
@rozgo
rozgo / gstreamer-module-build-cluster.md
Created August 7, 2019 04:32 — forked from Brainiarc7/gstreamer-module-build-cluster.md
Guide: How to build gstreamer from source on Ubuntu 16.04 for loading via the modules system

Build gstreamer from source (git checkouts):

Install build dependencies:

sudo apt-get install gtk-doc-tools liborc-0.4-0 liborc-0.4-dev libvorbis-dev libcdparanoia-dev libcdparanoia0 cdparanoia libvisual-0.4-0 libvisual-0.4-dev libvisual-0.4-plugins libvisual-projectm vorbis-tools vorbisgain libopus-dev libopus-doc libopus0 libopusfile-dev libopusfile0 libtheora-bin libtheora-dev libtheora-doc libvpx-dev libvpx-doc libvpx3 libqt5gstreamer-1.0-0 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libflac++-dev libavc1394-dev libraw1394-dev libraw1394-tools libraw1394-doc libraw1394-tools libtag1-dev libtagc0-dev libwavpack-dev wavpack

Extras:

@rozgo
rozgo / main.cpp
Created July 11, 2019 00:33 — forked from fogleman/main.cpp
Gray-Scott Reaction-Diffusion with OpenCL
#define CL_SILENCE_DEPRECATION
// #if defined(__APPLE__) || defined(__MACOSX)
// #include <OpenCL/cl.hpp>
// #else
// #include <CL/cl.hpp>
// #endif
#include "cl.hpp"
Encoder hevc_nvenc [NVIDIA NVENC hevc encoder]:
General capabilities: delay
Threading capabilities: none
Supported pixel formats: yuv420p nv12 p010le yuv444p yuv444p16le bgr0 rgb0 cuda
hevc_nvenc AVOptions:
-preset <int> E..V.... Set the encoding preset (from 0 to 11) (default medium)
default E..V....
slow E..V.... hq 2 passes
medium E..V.... hq 1 pass
fast E..V.... hp 1 pass