Skip to content

Instantly share code, notes, and snippets.

lemmy / SwitchLights.swift
Created December 26, 2023 18:34
Turn of lights when the display sleeps
import Foundation
import CoreGraphics
// Define the URL for the HTTP GET request
let baseURL = ""
// Create a URLSession
let session = URLSession.shared
// Define a function to create a task with a URL
lemmy / Simple.cfg
Last active December 24, 2022 04:28
lemmy / FoldSort.tla
Created March 5, 2022 18:32
No annotation found for Frob$1. Make sure that you've put one in front of Frob$1. E@18:30:44.591
----- MODULE FoldSort -----
EXTENDS Integers, Sequences, Apalache
\* @type: (Seq(Int), (a => Bool)) => Seq(Int);
FilterSeq(seq, cmp(_)) ==
--------------------------- MODULE TLAPlus2Grammar ---------------------------
EXTENDS Naturals, Sequences, BNFGrammars
CommaList(L) == L & (tok(",") & L)^*
AtLeast4(s) == Tok({s \o s \o s} & {s}^+)
ReservedWord ==
lemmy / settings.json
Created October 7, 2021 02:00
VSCode settings.json
"saveAndRunExt": {
"commands": [
"match": "\\.tla$",
"isShellCommand": false,
"silent": true,
"cmd": "tlaplus.debugger.smoke"
lemmy / Qsort.tla
Created June 12, 2021 03:06
A toy program to sort characters with QuickSort (implemented" in TLA+)
$ ./pluspy -s modules/other/Qsort.tla
Enter input: poiuylkjhmnbvcdsxzafgtrewq
----------------------------- MODULE Qsort -----------------------------
EXTENDS Naturals, Sequences, FiniteSets, TLC, Input
\* Specification (works reasonably well for sets of cardinality <= 6
\* Takes a set as argument, produces a sorted tuple
Sort(S) == CHOOSE s \in [ 1..Cardinality(S) -> S]:
lemmy / Echo.tla
Created August 3, 2020 19:43
-------------------------------- MODULE Echo --------------------------------
(* The Echo algorithm for constructing a spanning tree in an undirected *)
(* graph starting from a single initiator, as a PlusCal algorithm. *)
EXTENDS Naturals, FiniteSets, Relation, TLC
CONSTANTS Node, \* set of nodes
initiator, \* single initiator, will be the root of the tree
R \* neighborhood relation, represented as a Boolean function over nodes
* Copyright (c) 2018 Microsoft Research. All rights reserved.
* The MIT License (MIT)
* 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
lemmy / Installation
Last active December 11, 2019 17:19
TLC Execution Statistics Ingress into SQL for Analytics (Metabase)
apt-get install postgresql postgresql-11 postgresql-common postgresql-client-11 postgresql-client-common
apt-get install psycopg2 libpq-dev python-dev
apt-get install libapache2-mod-wsgi-py3 python-dev
apt-get install python3-flask
apt-get install python3-psycopg2