Skip to content

Instantly share code, notes, and snippets.

@whisper-bye
whisper-bye / psql-srv.py
Created April 28, 2024 09:26 — forked from eatonphil/psql-srv.py
postgres "server" wire protocol example (ported python3)
# th30z@u1310:[Desktop]$ psql -h localhost -p 55432
# Password:
# psql (9.1.10, server 0.0.0)
# WARNING: psql version 9.1, server version 0.0.
# Some psql features might not work.
# Type "help" for help.
#
# th30z=> select foo;
# a | b
# ---+---
@whisper-bye
whisper-bye / CalcitePosgresqlSchemaExample.java
Created April 15, 2024 07:50 — forked from egor-ryashin/CalcitePosgresqlSchemaExample.java
An example of Apache Calcite using Postgresql `pg_catalog` schema for validation.
package org.example;
import org.apache.calcite.adapter.jdbc.JdbcSchema;
import org.apache.calcite.jdbc.CalciteConnection;
import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.RelRoot;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.parser.SqlParseException;
@whisper-bye
whisper-bye / CalcitePosgresqlNewTableExample.java
Created April 15, 2024 07:50 — forked from egor-ryashin/CalcitePosgresqlNewTableExample.java
An example of Apache Calcite using a newly created Postgresql table for validation.
package org.example;
import org.apache.calcite.adapter.jdbc.JdbcSchema;
import org.apache.calcite.jdbc.CalciteConnection;
import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.RelRoot;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.parser.SqlParseException;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@whisper-bye
whisper-bye / GlobeVisualizer.cs
Created September 30, 2023 11:09 — forked from NegInfinity/GlobeVisualizer.cs
Spherical Worlds in Unity Tests - subdivision of sphere into tetrahedra, cube and adjusted cube
/*
#License:
MIT. Copyrigh 2022 Victor "NegInfinity" Eremin.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@whisper-bye
whisper-bye / reorder.c
Created March 14, 2022 07:26 — forked from skeeto/reorder.c
Observe memory reordering
#include <pthread.h>
#include <stdatomic.h>
#include <stdio.h>
#ifndef N
# define N 10000000
#endif
// Spin-lock barrier for two threads. Initialize to zero.
static void
@whisper-bye
whisper-bye / jdk8_optional_monad_laws.java
Created March 13, 2022 15:42 — forked from ms-tg/jdk8_optional_monad_laws.java
Does JDK8's Optional class satisfy the Monad laws? Yes, it does.
/**
* ```
* Does JDK8's Optional class satisfy the Monad laws?
* =================================================
* 1. Left identity: true
* 2. Right identity: true
* 3. Associativity: true
*
* Yes, it does.
* ```
@whisper-bye
whisper-bye / simplevm.c
Created December 4, 2021 05:10 — forked from imbushuo/simplevm.c
Demonstrates Hypervisor.Framework usage in Apple Silicon
// simplevm.c: demonstrates Hypervisor.Framework usage in Apple Silicon
// Based on the work by @zhuowei
// @imbushuo - Nov 2020
// To build:
// Prepare the entitlement with BOTH com.apple.security.hypervisor and com.apple.vm.networking WHEN SIP IS OFF
// Prepare the entitlement com.apple.security.hypervisor and NO com.apple.vm.networking WHEN SIP IS ON
// ^ Per @never_released, tested on 11.0.1, idk why
// clang -o simplevm -O2 -framework Hypervisor -mmacosx-version-min=11.0 simplevm.c
// codesign --entitlements simplevm.entitlements --force -s - simplevm
(*
* This file can be executed by running:
* $ ocaml -rectypes map-as-a-recursion-scheme.ml
*
*)
open Printf
(*
{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable, TypeFamilies, TemplateHaskell #-}
import Data.Functor.Foldable
import Data.Functor.Foldable.TH
import Data.Functor.Compose
-- Example type
data Exp
= IntValue Int
| Sum Exp Exp