Skip to content

Instantly share code, notes, and snippets.

View leafac's full-sized avatar

Leandro Facchinetti leafac

View GitHub Profile
#lang racket
(require redex)
(define-term initial-board [[· · ◼︎ ◼︎ ◼︎ · ·]
[· · ◼︎ ◼︎ ◼︎ · ·]
[◼︎ ◼︎ ◼︎ ◼︎ ◼︎ ◼︎ ◼︎]
[◼︎ ◼︎ ◼︎ ◻︎ ◼︎ ◼︎ ◼︎]
[◼︎ ◼︎ ◼︎ ◼︎ ◼︎ ◼︎ ◼︎]
[· · ◼︎ ◼︎ ◼︎ · ·]
#lang racket
; call/cc : ((α → β) → α) → α
; call/cc : ?
(+ 2 3)
(+ 2 (call/cc (λ (continuation) 3)))
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hilbert</title>
</head>
<body>
<svg width="600" height="600" viewBox="0 0, 1 1">
#SingleInstance force
![::
Send {“}
return
!+[::
Send {”}
return
const { Database, sql } = require("@leafac/sqlite");
const database = new Database("my-application.db");
const migrations = [
() => {
database.execute(
sql`
CREATE TABLE "users" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
@leafac
leafac / notes.md
Created August 25, 2021 13:19
Notes on Setting up Development Machines
@leafac
leafac / notes.md
Created August 25, 2021 13:22
Notes on Timezones in Node.js & SQLite Applications
  • SQLite’s datetime functions are all UTC, but they don’t explicitly include the timezone information
  • In JavaScript (browsers & Node.js) datetimes without explicit timezone information are interpreted as local time
  • In servers (for example, DigitalOcean & GitHub Actions machines) the timezone is usually set to UTC
  • In development, the timezone is set to the user’s timezone
  • We can change the timezone for the Node.js process in macOS/Linux with the TZ=UTC environment variable
  • On Windows, the only solution is to temporarily change the OS timezone
  • This sounds too heavy-handed and storing datetimes without an explicit timezone seems like a bad idea, anyway
  • So the best solution that works everywhere is to avoid using SQLite datetime functions for generating values that will be stored in the database (it’s still fine to use them for queries)
  • To be exact, I’m talking about SQLite’s CURRENT_TIMESTAMP, datetime() and so forth
  • The correct way of doing it is using the more generic SQLite datetime function
@leafac
leafac / notes.md
Created August 25, 2021 13:26
Quirks of Client-Side Form Validation
  • ‘required’ doesn’t stop the field from being whitespace
  • ‘pattern’ isn’t checked if the field is left empty and it isn’t ‘required’
  • You can do ‘required pattern=".\S."’ if you want a quick-and-dirty solution
@leafac
leafac / init.lua
Created August 25, 2021 14:54
Hammerspoon Snippets
hs.alert("Hammerspoon configuration loaded")
hs.hotkey.bind({"⌥", "⌃"}, "return", function() hs.reload() end)
hs.hotkey.bind({"⌥", "⌃"}, ",",
function() hs.execute([[code ~/.hammerspoon]], true) end)
hs.hotkey.bind({"⌥", "⌃"}, "space", function() hs.toggleConsole() end)
hs.hotkey.bind({"⌥", "⌃"}, "escape", function()
hs.osascript.applescript("beep")
hs.sound.getByName("Submarine"):play()
end)