Skip to content

Instantly share code, notes, and snippets.

View rsms's full-sized avatar

Rasmus rsms

View GitHub Profile
@rsms
rsms / macos-distribution.md
Last active July 26, 2024 07:54
macOS distribution — code signing, notarization, quarantine, distribution vehicles
@rsms
rsms / time_diff.js
Last active July 5, 2024 06:56
Relative time between two points in time, expressed in years → months → weeks → days → hours → seconds → milliseconds, accounting for leap years and days-in month.
function time_diff(date1, date2) {
var future_date, past_date;
date1 < date2 ? (past_date = date1, future_date = date2)
: (past_date = date2, future_date = date1);
var D = {},
t = future_date - past_date,
SECOND = 1000,
MINUTE = 6e4,
HOUR = 36e5, // 60 minutes
DAY = 864e5, // 24 hours
// Find the latest version of this script here:
// https://gist.github.com/rsms/a8ad736ba3d448100577de2b88e826de
//
const EM = 2048
interface FontInfo {
familyName :string
styleName :string
unitsPerEm :int
ascender :int
@rsms
rsms / playbit-vconsole.sh
Last active July 4, 2024 00:57
Script for connecting to Playbit development console
#!/bin/sh
set -eo pipefail
SOCKFILE="$HOME/Library/Application Support/Playbit/vconsole0.sock"
while [ $# -gt 0 ]; do case "$1" in
-h|-help|--help) cat <<END
Connect a terminal to Playbit
Usage: $0 [--help | <sockfile>]
<sockfile> defaults to $SOCKFILE

Fixing macOS 10.14, 10.15, 12

Dark main menu without the rest of dark mode

  1. Set Light mode
  2. defaults write -g NSRequiresAquaSystemAppearance -bool Yes
  3. Log out and log back in
  4. Set Dark mode
@rsms
rsms / Implementing Software Timers.md
Created October 13, 2012 08:14
This column will describe a set of functions to implement software timers.

Implementing Software Timers

By Don Libes

Originally appeared in the Nov. 1990 "C User's Journal" and is also reprinted as Chapter 35 of "Obfuscated C and Other Mysteries", John Wiley & Sons, 1993, ISBN 0-471-57805-3. http://www.wiley.com/compbooks/m3.html.

This column will describe a set of functions to implement software

@rsms
rsms / figma-project-stats.js
Created June 21, 2018 19:17
Script that generates statistics for a Figma project, like number of files, frames, versions etc
//
// Figma project stats
// Pulls statistics like number of files, frames, versions etc for a project.
//
// Usage:
// export FIGMA_API_ACCESS_TOKEN='your-token'
// node figma-project-stats.js <project-id>
//
// You can generate tokens in your account settings or at
// https://www.figma.com/developers/explorer#personal-access-token
@rsms
rsms / fig-thumbnails.js
Created November 18, 2019 23:33
Script to fetch thumbnails of figma files
// 1. Make sure you have imagemagick installed (`brew install imagemagick` on macos)
// 2. Visit https://www.figma.com/developers/api#authentication and click "Get personal access token"
// 3. Add your file links below, replacing the example links
// 4. Run with `FIGMA_API_TOKEN=YOUR_TOKEN_FROM_STEP_2_HERE node fig-thumbnails.js`
// [ host:string, filekey:string ][]
const fileKeys = `
https://www.figma.com/file/FILEKEY/
https://staging.figma.com/file/FILEKEY/
https://www.figma.com/file/FILEKEY/
// cc -std=c11 miniast.c -o miniast && ./miniast
#include "xcommon.h"
ASSUME_NONNULL_BEGIN
typedef enum AKind {
AKindInt, // 123
AKindAdd, // +
AKindSub, // -
AKindMul, // *
} AKind;