Skip to content

Instantly share code, notes, and snippets.

-- vim: tabstop=2 shiftwidth=2 expandtab
-- We almost always start by importing the wezterm module
local wezterm = require 'wezterm'
-- Define a lua table to hold _our_ module's functions
local module = {}
-- Returns a bool based on whether the host operating system's
-- appearance is light or dark.
function module.is_dark()
@jonahwilliams
jonahwilliams / main.dart
Created March 27, 2022 00:05
Hot Reload for Dart CLI
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:vm_service/vm_service_io.dart';
void main() async {
var process = await Process.start('dart', ['run', '--enable-vm-service', 'lib/main.dart']);
var completer = Completer<String>();
process.stdout
.transform(utf8.decoder)
@maratori
maratori / .golangci.yml
Last active November 15, 2024 14:06
Golden config for golangci-lint
# This code is licensed under the terms of the MIT license https://opensource.org/license/mit
# Copyright (c) 2021 Marat Reymers
## Golden config for golangci-lint v1.62.0
#
# This is the best config for golangci-lint based on my experience and opinion.
# It is very strict, but not extremely strict.
# Feel free to adapt and change it for your needs.
run:
@kahole
kahole / index.html
Last active October 10, 2024 20:28
*scratch*.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>*scratch*</title>
<style>
body {
font-family: Hack, Menlo, Monaco, 'Droid Sans Mono', 'Courier New', monospace;
white-space: pre;
@onlurking
onlurking / programming-as-theory-building.md
Last active November 13, 2024 17:31
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

/**
* Export all data from an IndexedDB database
*
* @param {IDBDatabase} idbDatabase The database to export from
* @return {Promise<string>}
*/
export function exportToJson(idbDatabase) {
return new Promise((resolve, reject) => {
const exportObject = {}
if (idbDatabase.objectStoreNames.length === 0) {
@fnky
fnky / ANSI.md
Last active November 16, 2024 01:32
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@pjstadig
pjstadig / core.clj
Created March 20, 2017 13:06
A little type hint hint
(ns typehint.core)
;; A little type hint hint...
(set! *warn-on-reflection* true)
;; There are two ways to type hint the return value of a function, but one is
;; (technically) wrong:
(defn ^String as-string0
@reborg
reborg / rich-already-answered-that.md
Last active September 25, 2024 17:06
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@favila
favila / entity-changes.clj
Last active October 16, 2019 13:14
enity-changes Return transaction history for a datomic entity and its components.
(require '[datomic.api :as d])
(defn entity-changes
"Return transaction history for an entity and its components.
Returns a sequence of maps, each is the transaction map (tx metadata) plus a
key `:entity-changes`, which is a nested map of keys: entity id, attribute
ident, `:db/add` or `:db/retract`, and the value added or retracted, e.g.:
{12345678910 {:long-card-1-attr {:db/retract 1
:db/add 0}
:long-card-many-attr {:db/add #{0}}