Skip to content

Instantly share code, notes, and snippets.

dev:
quarkus dev
jshell:
#!/usr/bin/env jbang --jsh
//DEPS com.github.javafaker:javafaker:1.0.2
var faker = new com.github.javafaker.Faker();
println(faker.nation().nationality());
java:
@visortelle
visortelle / README.md
Last active July 2, 2023 07:12
Aliases for Apache Pulsar CLI tools with JWT auth. Add it to your ~/.bashrc or ~/.zshrc.

Aliases for Apache Pulsar CLI tools with JWT auth

Usage

  • Add the pulsar-cli-aliases.shfile content to your ~/.bashrc or ~/.zshrc.
  • Fill pulsar_jwt, pulsar_url, pulsar_admin_url with your values.
  • Then use short commands like pa topics stats public/default/topic-a instead of
pulsar-admin \
@andrewrk
andrewrk / build.zig
Created February 20, 2023 16:20
sprinkling a little zig into a C project to help with debugging
const std = @import("std");
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard optimization options allow the person running `zig build` to select
@dustingetz
dustingetz / a.md
Last active September 12, 2022 13:32
Photon demo: database branching (time travel)

Photon demo: database branching (time travel)

  • This demo uses DataScript's API for speculative transactions, not sure if can be done with sql read transactions.
  • DataScript is on the server; code is network-transparent.
  • 100 LOC for everything (table, query, popover, css, page)
20220910.branched.popover.staging.area.2.mp4
@otobrglez
otobrglez / Main.scala
Last active May 27, 2021 06:35
Exploring Cats Effect and sttp
// Oto Brglez - <[email protected]> - May 2021
package com.pinkstack.gen4
import cats.effect.implicits._
import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
import com.pinkstack.gen1.CoinMarketCap.Implicits._
import com.pinkstack.gen1.CoinMarketCap._
import sttp.client3._
import sttp.client3.circe._
@kubukoz
kubukoz / http4s-onEmptyOrNonEmpty.scala
Last active April 2, 2021 14:24
Return NotFound if http4s response stream is empty, wrap it in a different status otherwise
/*
Copyright 2021 Jakub Kozłowski
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@serras
serras / variants.md
Created August 31, 2020 19:37
Variants: the ultimate frontier

Variants: the ultimate frontier

Most data serialization formats, like JSON, YAML, and EDN, feature a similar set of basic building blocks, namely:

  • Some primitive values, like numbers, strings, and booleans;
  • Key-value pairs, also known as maps, dictionaries, or objects;
  • Sequences, usually in the form of lists or arrays, and sometimes also sets.

I completely agree with the fact that those are basic building blocks for data inside any information system. However, as a Haskeller I always miss one additional part of my toolbox: variants. Variants are essentially tagged values which contain further values inside.

@dacr
dacr / index.md
Last active October 16, 2024 19:54
David's programming examples knowledge base / published by https://github.com/dacr/code-examples-manager #fecafeca-feca-feca-feca-fecafecafeca/16e5e3ae008b840d9fabb81cecb8edcf384a94a1

David's programming examples knowledge base

akka-pekko

@lizthegrey
lizthegrey / attributes.rb
Last active September 24, 2024 14:33
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@mpilquist
mpilquist / switchMap.scala
Created March 18, 2017 17:13
FS2 version of switchMap
def switchMap[F[_]: Async, A, B](f: A => Stream[F, B]): Pipe[F, A, B] = {
def go(
outer: ScopedFuture[F, Pull[F, Nothing, (NonEmptyChunk[A], Handle[F, A])]],
inner: ScopedFuture[F, Pull[F, Nothing, (NonEmptyChunk[B], Handle[F, B])]]
): Pull[F, B, Nothing] = {
(outer race inner).pull.flatMap {
case Left(outer) =>
outer.optional.flatMap {
case None =>
inner.pull.flatMap(identity).flatMap { case (hd, tl) => Pull.output(hd) >> tl.echo }