Skip to content

Instantly share code, notes, and snippets.

View loicknuchel's full-sized avatar
👨‍💻
Explore your database => https://azimutt.app

Loïc Knuchel loicknuchel

👨‍💻
Explore your database => https://azimutt.app
View GitHub Profile
@loicknuchel
loicknuchel / DemoSpec.scala
Last active November 11, 2020 14:50
SQL DSL: use shapeless to require correct Put instances
import cats.effect.{ContextShift, IO}
import doobie.syntax.connectionio._
import doobie.syntax.string._
import doobie.util.Put
import doobie.util.fragment.Fragment
import doobie.util.fragment.Fragment.const0
import doobie.util.transactor.Transactor
import org.scalatest.BeforeAndAfterEach
import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers
@loicknuchel
loicknuchel / tailwind-class-check.js
Created February 4, 2022 23:39
Check if tailwind classes are correctly generated
/*
Using tailwind 3 CLI when generating dynamic classes can sometimes be quite painful as you never know which classes may be missing.
Not anymore with this script!
It gets your stylesheets, then all your classes in HTML and print classes that are present in HTML but not in stylesheets.
*/
function identifyMissingClasses() {
getStyles().then(styles => {
const classes = getClassCounts(document.getElementsByTagName('html')[0])
const matches = matchClassesInStyles(styles, classes)
const misses = filterMissingClasses(matches)
@loicknuchel
loicknuchel / pg_catalog_schema.js
Last active July 13, 2022 20:50
Generate AML from PostgreSQL documentation
// to execute in the console of https://www.postgresql.org/docs/current/catalog-pg-class.html
// and paste the copied result into https://azimutt.app ;)
function generateTableAml() {
const url = window.location.href
const table_schema = 'pg_catalog'
const table_name = document.querySelector('h2.title .structname').textContent
const table_description = document.querySelector('p').textContent
const column_rows = Array.from(document.querySelector('.table-contents').querySelectorAll('tbody tr'))
const columns = column_rows.map(r => {
return {