Skip to content

Instantly share code, notes, and snippets.

View romac's full-sized avatar
🔮
λ

Romain Ruetschi romac

🔮
λ
View GitHub Profile
@heaths
heaths / workspace-dependencies.rs
Last active February 27, 2024 09:27
Rust script to verify that package dependencies are inherited from single workspace.
#!/usr/bin/env -S cargo +nightly -Zscript
---
[package]
edition = "2021"
[dependencies]
cargo-util-schemas = "0.1.0"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
toml = "0.8.10"
@gelisam
gelisam / MutuCheckInfer.hs
Last active November 4, 2023 03:44
A recursion scheme for mutually-recursive types
-- Defining a custom recursion scheme to manipulate two mutually-recursive
-- types, in the context of a toy bidirectional type checker.
{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving, ScopedTypeVariables #-}
module Main where
import Test.DocTest
import Control.Monad (when)
import Data.Bifunctor (Bifunctor(bimap))
import Data.Bifoldable (Bifoldable(bifoldMap), bitraverse_)
@sainoe
sainoe / change_voting_period
Last active October 17, 2022 15:59
testnet-scripts
#!/bin/bash
set -eux
```
tee ${PROV_NODE_DIR}/change-voting-period.json<<EOF
{
"title": "Change voting period",
"description": "Voting period",
"changes": [
@piperswe
piperswe / build_push_and_run.sh
Created April 17, 2021 01:53
Build multi-architecture Docker images with Nix
#!/bin/sh
# Required on macOS because cctools is marked as broken
export NIXPKGS_ALLOW_BROKEN=1
nix run -f image.nix -c push
docker run ghcr.io/piperswe/hello
@SergeiMeza
SergeiMeza / macOS_ChatApp_Main.swift
Last active June 21, 2023 09:31
Chat App Client (UI) for macOS in SwiftUI
// Main
@main
struct ChatApp_macOSApp: App {
var body: some Scene {
WindowGroup {
Home()
}
// Hiding Title Bar...
.windowStyle(HiddenTitleBarWindowStyle())
@romac
romac / README.md
Last active June 19, 2020 10:20
Switch between iTerm profiles based on the active macOS theme
@scottmatthewman
scottmatthewman / AdaptsToSoftwareKeyboard.swift
Last active April 19, 2024 12:56
An example of using Combine to automatically adapt a SwiftUI scrollable view to accommodate an iOS onscreen keyboard
import SwiftUI
import Combine
struct AdaptsToSoftwareKeyboard: ViewModifier {
@State var currentHeight: CGFloat = 0
func body(content: Content) -> some View {
content
.padding(.bottom, currentHeight)
.edgesIgnoringSafeArea(.bottom)
@mosen
mosen / Share.swift
Created March 6, 2018 04:55
Convenient swift-like wrapper over NetFS smb mounting
import Foundation
import NetFS
enum ShareMountError: Error {
case InvalidURL
case MountpointInaccessible
case InvalidMountOptions
}
@non
non / laws.md
Last active February 20, 2022 00:26
I feel like conversations around laws and lawfulness in Scala are often not productive, due to a lack of rigor involved. I wanted to try to be as clear and specific as possible about my views of lawful (and unlawful) behavior, and what I consider a correct and rigorous way to think about laws (and their limits) in Scala.

Laws

A law is a group of two or more expressions which are required to be the same. The expressions will usually involve one or more typed holes ("inputs") which vary.

Some examples:

x.map(id) === x
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}