Skip to content

Instantly share code, notes, and snippets.

@mjmsmith
mjmsmith / PaddingModifier.swift
Last active December 19, 2024 21:18
Padding modifier for SwiftUI views.
// NOTE: Nil values implicitly or explicitly passed as arguments to padding() are ignored.
// This differs from the built-in SwiftUI version:
//
// view.padding(trailing: nil) // has no effect
// view.padding(.trailing, nil) // resets to default
//
// See below for a version that matches the built-in behavior.
extension View {
func padding(horizontal: CGFloat? = nil, vertical: CGFloat? = nil,
//
// OCXML.swift
// Created by Marco Arment on 9/23/24.
//
// Released into the public domain. Do whatever you'd like with this.
// No guarantees that it'll do anything, or do it correctly. Good luck!
//
import Foundation
@adactio
adactio / updateDateTimes.js
Last active September 11, 2023 05:10
Periodically update the text of `datetime` elements with the relative time elapsed.
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.Intl || !win.Intl.RelativeTimeFormat) {
// doesn't cut the mustard.
return;
}
var rtf = new Intl.RelativeTimeFormat('en', {
localeMatcher: 'best fit',
numeric: 'always',
style: 'long'
@ttscoff
ttscoff / toot.rb
Last active April 28, 2023 04:58
Scans RSS feed for latest post and creates Mastodon toot
#!/usr/bin/env ruby -W1
# frozen_string_literal: true
# This script scans an RSS feed for the latest post, and if
# it hasn't already been posted to Mastodon, creates a new
# toot with a link to it.
require 'json'
require 'optparse'
require 'rss'
@chockenberry
chockenberry / ql.sh
Last active March 4, 2024 23:40
QuickLook for macOS shell
#!/bin/sh
# usage:
# ql /tmp/file.jpg
# cat /tmp/file.jpg | ql
# cal -h | ql
if [ -z "$*" ]; then
cat > /tmp/ql.stdin
mime_type=$(file --brief --mime-type /tmp/ql.stdin)
@kentcdodds
kentcdodds / session.server.ts
Created November 18, 2021 21:04
Authentication in Remix applications
import * as bcrypt from "bcrypt";
import { createCookieSessionStorage, redirect } from "remix";
import { db } from "./db.server";
export type LoginForm = {
username: string;
password: string;
};
@henrik242
henrik242 / Global macOS hotkeys for Google Meet, Spotify and others using AppleScript and Fastscripts.md
Last active February 7, 2025 23:03
Global macOS hotkeys for Google Meet, Spotify and others using AppleScript and Fastscripts
@lancethomps
lancethomps / close_notifications_applescript.js
Last active January 30, 2025 09:51
AppleScript to close all notifications on macOS Big Sur, Monterey, Ventura, Sonoma, and Sequoia
function run(input, parameters) {
const appNames = [];
const skipAppNames = [];
const verbose = true;
const scriptName = 'close_notifications_applescript';
const CLEAR_ALL_ACTION = 'Clear All';
const CLEAR_ALL_ACTION_TOP = 'Clear';
const CLOSE_ACTION = 'Close';
@mzeryck
mzeryck / mz_invisible_widget.js
Last active February 15, 2025 19:28
A Scriptable script that creates "invisible" widget backgrounds based on your iOS wallpaper, and then either uses them as a Scriptable widget background or exports to your camera roll.
/*
MIT License
Copyright (c) 2024 Maxwell Zeryck
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTW
@alexlouden
alexlouden / 0_usage.js
Last active October 31, 2019 11:33
Custom styled scrollbars
import React from 'react'
import useCustomScrollbars, { scrollbarWidth } from './useCustomScrollbars'
const Container = React.forwardRef(({ bg, children, ...props }, ref) => {
const [localRef, scrollbarsShown, scrollbarStyles] = useCustomScrollbars(
children,
ref,
bg
)