Skip to content

Instantly share code, notes, and snippets.

View igstan's full-sized avatar

Ionuț G. Stan igstan

View GitHub Profile
@igstan
igstan / css-3d-transforms.html
Created July 7, 2024 11:46
CSS 3D Transforms & Animations
<!DOCTYPE html>
<!-- Demo: https://www.youtube.com/watch?v=7M9aPgORP_E -->
<html>
<head>
<meta charset="UTF-8">
<title>CSS 3D Transforms &amp; Animations</title>
<style type="text/css">
* {
object YAML:
apiVersion:
apps/v1
kind:
Deployment
metadata:
name:
"my-app"
namespace:
"my-app"
@igstan
igstan / pratt.sh
Last active June 8, 2024 11:45
Arithmetic evaluator in pure Bash using Pratt parsing
#!/usr/bin/env bash
#
# RESOURCES
#
# - https://tdop.github.io/
# - https://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/
# - https://martin.janiczek.cz/2023/07/03/demystifying-pratt-parsers.html
#
@igstan
igstan / clone-gists.sh
Last active May 30, 2024 17:35
Clone all your GitHub gists, public or private.
#!/usr/bin/env bash
# Clones all gists (public or private) into directory `gists/` (auto-created
# and configurable if desired). The cloned gists are placed into directory
# names formed from the name of the first file found in the gist concatenated
# to the gist ID. For example, this gist will be cloned into:
#
# gists/clone-gists.sh-0a89b8bb1a6df0754647cdd87d8221b6
#
# USAGE:
#!/usr/bin/env osascript -l JavaScript
ObjC.import('stdlib')
ObjC.import('PDFKit');
function reverse(opts) {
// Load the PDF document
const pdfURL = $.NSURL.fileURLWithPath(opts.src);
const pdfDoc = $.PDFDocument.alloc.initWithURL(pdfURL);
@igstan
igstan / nulls-nulls-everywhere.sql
Created May 15, 2024 19:16
SQL NULL & JSON NULL
SELECT
jsonb_set(
'{"deeply": {"nested": {"field": 1}}}'::jsonb,
'{deeply,nested,field}',
to_jsonb(NULL::int)
) AS with_null_arg,
jsonb_set(
'{"deeply": {"nested": {"field": 1}}}'::jsonb,
'{deeply,nested,field}',
@igstan
igstan / jitted.c
Created November 30, 2022 20:08
Hello World JIT for Apple Silicon
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sys/mman.h>
static uint8_t code[] = {
0x40, 0x05, 0x80, 0x52, // mov w0, #3
0xc0, 0x03, 0x5f, 0xd6, // ret
module Seq = struct
include Seq
let rec fold_right : 'a Seq.t -> 'b -> ('a -> 'b Lazy.t -> 'b Lazy.t) -> 'b Lazy.t =
fun seq acc f ->
match seq () with
| Seq.Nil -> lazy acc
| Seq.Cons (a, rest) -> f a (lazy (Lazy.force (fold_right rest acc f)))
let map : ('a -> 'b) -> 'a Seq.t -> 'b Seq.t =
trait SACVisitor[R] {
def c1(a: Int): R
def c2(a: R, b: R): R
}
sealed trait SAC extends Product with Serializable {
def fold[R](visitor: SACVisitor[R]): R
}
object SAC {
import cats.implicits._
import cats.Monad
import cats.data.State
//
// Two capability/tagless final traits: Foo & Bar
//
trait Foo[F[_]] {
def foo: F[Unit]
}