Skip to content

Instantly share code, notes, and snippets.

@petrilli
petrilli / main.py
Last active January 5, 2024 19:50
Example combination of FastAPI and Pydantic with aiosql and aiosqlite
# -*- coding: utf-8 -*-
"""Example combination of FastAPI and Pydantic with aiosql and aiosqlite.
This module demonstrates the minimum viable integration approach for putting
together a few components:
- FastAPI. This provides a very high-performance and type-driving approach to
building APIs in Python
- Pydantic. A powerful data validation library.
- aiosql. Inspired by annosql and originally Clojure's yeSql, a way to programatically,
@gvolpe
gvolpe / build.sbt
Last active September 29, 2023 10:26
Minimal SBT build for pfps-examples
ThisBuild / scalaVersion := "2.13.5"
lazy val root = (project in file("."))
.settings(
name := "minimal",
libraryDependencies ++= Seq(
compilerPlugin(
"org.typelevel" %% "kind-projector" % "0.11.3"
cross CrossVersion.full
),
@jaburns
jaburns / genindex.cpp
Last active March 10, 2023 18:10
Generational indices in C++ vs Rust
/*
Copyright 2021 Jeremy Burns
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR O
@3noch
3noch / phpWith.nix
Created March 28, 2017 21:18
PHP with configuration in Nix
{ pkgs ? import <nixpkgs> {}
, phpPackage ? pkgs.php
, phpPackages ? pkgs.phpPackages
, opCache ? false
, showErrors ? false
, extensions ? []
, zendExtensions ? []
, extraConfig ? ""
}:
let

Using nc and protoc as protobuf client and server

Inspiration: Linux and Unix nc command

Example protobuf definition:

message Person {
  required string name = 1;
  required int32 id = 2;
@tmspzz
tmspzz / install-haskell-stack-arm.sh
Last active April 28, 2019 07:00
A scrip to install Haskell Stack and set up things properly on Raspbian
#!/bin/sh
# Update: As of March 24th 2017 this script won't work.
# The script at https://get.haskellstack.org/ is broken
# because the binary of Stack 1.4 for ARM is missing from https://www.stackage.org/stack/ .
# You can still get the binary for Stack 1.3.2 from
# https://github.com/commercialhaskell/stack/releases/download/v1.3.2/stack-1.3.2-linux-arm.tar.gz
# and place it at $USR_LOCAL_BIN/stack in your system.
# Once Stack is installed you can proceed with the Install LLVM step
@warmfusion
warmfusion / README.md
Last active June 4, 2021 14:50
Notes from building ETCD / Confd / Haproxy autoconfiguration environment

The following documents a trial of using etcd, and confd to automatically configure a haproxy load balancer.

It is built using a combination of blogs, resources and experimentation, but provides a rough template of the approach that would allow a fully featured balancer to be configured from etcd keyvalues.

TODO

  • Include systemd sidekick unit to automatically register the key's into ETCD based on a docker service (for example) being started
  • A more complete haproxy template that builds a valid, complex haproxy that would be capable of dealing with Future PLC's balancer requirements
@stesie
stesie / index.html
Created April 1, 2016 22:28
AWS IoT-based serverless JS-Webapp Pub/Sub demo
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>AWS IoT Pub/Sub Demo</title>
</head>
<body>
<h1>AWS IoT Pub/Sub Demo</h1>
<form>
<button type="button" id="connect">connect!</button>
module Printf
%default total
data Format = FInt Format -- %d
| FString Format -- %s
| FOther Char Format -- [a-zA-Z0-9]
| FEnd --
format : List Char -> Format
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell