Skip to content

Instantly share code, notes, and snippets.

@geobabbler
geobabbler / scrape_photos.py
Created July 19, 2024 11:01
Script to download sample images from Wikimedia Commons
import requests
from bs4 import BeautifulSoup
import os
qry = "glacier" #wikimedia commons query
# Define the search URL
search_url = f"https://commons.wikimedia.org/w/index.php?search={qry}&title=Special:MediaSearch&go=Go&type=image"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
package main
import (
"bytes"
"compress/zlib"
"crypto/sha1"
"encoding/hex"
"fmt"
"io"
"log"
aahed
aalii
aapas
aargh
aarti
abaca
abaci
aback
abacs
abaft
@robmiller
robmiller / play-wordle.rb
Last active February 15, 2022 19:40
A command-line, offline version of Wordle. A new word every time you run it.
#!/usr/bin/env ruby
#
# Play a command-line version of Wordle
#
# Original game by Josh Wardle: https://www.powerlanguage.co.uk/wordle/
#
# Installation and usage:
#
# 1. Save this file somewhere as play-wordle.rb
# 2. Run `ruby play-wordle.rb`
@xenatisch
xenatisch / cache_repopulation-normal.sql
Created November 21, 2021 12:02
Normal and optimised versions of Postgres (Citus) queries and plans thereof
SELECT
'area-' || release_date::TEXT || '-' || area_id::TEXT AS key,
JSONB_AGG(
JSONB_BUILD_OBJECT(
'area_code', area_code,
'area_type', area_type,
'area_name', area_name,
'date', to_char(date::DATE, 'YYYY-MM-DD'),
'metric', metric,
'value', value,
@joerodgers
joerodgers / Export-UnifiedGroupMetadataToCsv.ps1
Last active November 20, 2024 14:52
Example of using the Microsoft.Graph PowerShell module to read basic metadata about all unified groups and dump results to csv.
#requires -modules "Microsoft.Graph.Authentication", "Microsoft.Graph.Groups", "Microsoft.Graph.Files"
<#
App Principal Permissions Required, must have any one permission for each of the three cmdlets.
Get-MgGroup == GroupMember.Read.All, Group.Read.All, Directory.Read.All, Group.ReadWrite.All, Directory.ReadWrite.All
Get-MgGroupOwner == GroupMember.Read.All, Group.Read.All, GroupMember.ReadWrite.All, Group.ReadWrite.All, Directory.Read.All
Get-MgGroupDrive == Files.Read.All, Files.ReadWrite.All, Sites.Read.All, Sites.ReadWrite.All
#>
@hwayne
hwayne / explanation.md
Last active April 9, 2024 21:37
Sudoku DIMACS format

How the J Script Works

Going line by line:

b =: >: i. 9 9 9

This generates a 9 by 9 by 9 array with all values from 1 to 729. We can choose what each axis represents: I decided that each table is all of the boolean variables for one number, and the rows and columns map to sudoku rows and columns. For example:

#lang racket
(define (expr? e)
(match e
[(? symbol? x) #t]
[`(lambda (,(? symbol? x)) ,(? expr? e-body)) #t]
[`(,(? expr? e0) ,(? expr? e1)) #t]
[_ #f]))
(define (free-vars e)
@nachocodexx
nachocodexx / erik-meijer-books.md
Created January 26, 2021 15:09
Erik Meijer’s List of Recommended Books

Erik Meijer’s List of Recommended Books

  1. Logic and Computation: Interactive Proof with Cambridge LCF (Cambridge Tracts in Theoretical Computer Science)
  2. Mathematical Theory of Programme Correctness (Prentice-Hall International series in computer science)
  3. The Haskell School of Expression: Learning Functional Programming through Multimedia
  4. LaTeX: A Document Preparation System (2nd Edition)
  5. Denotational Semantics
  6. Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory
  7. Programs and Machines
  8. The Denotational Description of Programming Languages: An Introduction
@smhanov
smhanov / OpenType.ts
Last active March 30, 2025 18:19
Here is my implementation of a TrueType font reader in Typescript. You can read a font directly from an ArrayBuffer, and then call drawText() to draw it. See my article http://stevehanov.ca/blog/index.php?id=143. The second file, OpenType.ts is the same thing but it handles more TrueType files. It is also more coplex
// To see this run, you first stub out these imports. Then put the file in a Uint8Array.
// let slice = new Slice(array);
// let font = new OTFFont(slice);
// Then you can call methods like font.drawText(canvasContext, )
//
//
import { ICanvasContext } from "./ICanvasContext"
import { log as Log } from "./log"
const log = Log.create("OPENTYPE");