Skip to content

Instantly share code, notes, and snippets.

@rickosborne
rickosborne / mastodon-thread-to-json.js
Last active April 23, 2023 23:45
Bookmarklet to extract a Mastodon thread into JSON
javascript:(function () {
/* ========================================
Mastodon thread scraper, by Rick Osborne.
Copy this entire file, from the opening "javascript:" to the last "();".
Create a new bookmark in your browser, using the copied text as the URL.
When you are on a Mastodon thread page, activate this bookmark.
======================================== */
function findOne(parent, selector, block) {
if (parent == null) {
return undefined;
// Before 😕
let doingSomethingToOptionalView1: CGFloat? = {
guard let firstSubview = subviews.first else { return nil }
return (firstSubview.bounds.width / 2.0) + otherView.bounds.width
}()
// After 😊
let doingSomethingToOptionalView2 = subviews.first.useIfNotNil { ($0.bounds.width / 2.0) + otherView.bounds.width }
@marcoarment
marcoarment / S3.php
Last active June 25, 2023 19:41
A simple PHP class to perform basic operations against Amazon S3 and compatible services.
<?php
/*
A simple PHP class to perform basic operations against Amazon S3 and compatible
services. Requires modern PHP (7+, probably) with curl, dom, and iconv modules.
Copyright 2022 Marco Arment. Released under the MIT license:
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
@kingkool68
kingkool68 / examples.php
Created June 23, 2022 20:45
Helper functions to make generating WordPress post type labels and taxonomy labels easier
<?php
// Register a Book post type
$args = array(
'labels' => generate_post_type_labels( 'book', 'books' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
@kingfisher1234
kingfisher1234 / gist:caf351bed786f9050e1fa28c3352ded9
Last active January 12, 2022 18:11
Physical mute button for Zoom using an ATTiny85/Digispark and the Micronucleus bootloader to allow programming with the Arduino IDE - Mac Version
/*
Thanks to Elliotmade for the inspiration on this project
https://elliotmade.com/2020/04/23/physical-mute-button-for-zoom-meetings/
Refactored by HaxNobody to extend functionalty
https://gist.github.com/HaxNobody/7bde369d7a41348b8b91c1a4f358ea4a#file-zoommutebutton-ino
This program will send USB HID keyboard presses to bring the Zoom window into
the foreground and activate microphone and video functions.
* A momentary press on button 1 will toggle mute on or off.
* Press and hold button 1 to close zoom (Zoom Needs to be in focus on a Mac (Or you will close a different window)).
*/
@juhagman
juhagman / Wikimedia.swift
Last active May 26, 2017 09:35
Swift playgrounds code to filter Wikimedia browser stats
import Foundation
let tab = CharacterSet(charactersIn: "\t")
let newline = CharacterSet(charactersIn: "\n")
let fmt = DateFormatter() ; fmt.dateFormat = "YYYY-mm-DD"
let dateRanges = [
(fmt.date(from: "2015-01-01"), fmt.date(from: "2016-01-01")),
(fmt.date(from: "2016-01-01"), fmt.date(from: "2017-01-01")),
(fmt.date(from: "2017-01-01"), fmt.date(from: "2018-01-01")),
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function custom_posts_where_sql_for_only_expired() {
return ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end < "' . current_time( 'mysql', TRUE ) . '"
AND post_status = "publish"';
}
add_action( 'loop_start', 'my_custom_event_view_only_expired' );
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#define WIFI_SSID "yourssid"
#define WIFI_KEY "yourkey"
#define NOTIFY_URL "http://maker.ifttt.com/trigger/<eventname>/with/key/<yourkey>"
#define SECOND 1000
#define QUARTER_SECOND 250
@max-mapper
max-mapper / readme.md
Last active March 16, 2023 15:18
Video stabilization using VidStab and FFMPEG (Mac OS X)

Video stabilization using VidStab and FFMPEG

Examples here use the default settings, see the VidStab readme on GitHub for more advanced instructions.

Here's an example video I made

Install ffmpeg with the vidstab plugin from homebrew

brew install ffmpeg --with-libvidstab
@jessepearson
jessepearson / acf-update-via-json.php
Created March 24, 2015 12:58
Automatically update Advanced Custom Fields field groups via JSON
<?php
/**
* Function that will automatically update ACF field groups via JSON file update.
*
* @link http://www.advancedcustomfields.com/resources/synchronized-json/
*/
function jp_sync_acf_fields() {
// vars