This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Public IP Tidbyt App | |
# MIT License | |
# by Nicholas Penree, Dec 28 2021 | |
load("render.star", "render") | |
load("http.star", "http") | |
load("cache.star", "cache") | |
IPIFY_JSON_URL = "https://api.ipify.org/?format=json" | |
MOCK = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = Application.currentApplication() | |
app.includeStandardAdditions = true | |
function getJSON(path) { | |
const fullPath = path.replace(/^~/, app.pathTo('home folder')) | |
const contents = app.read(fullPath) | |
return JSON.parse(contents) | |
} | |
function run() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# SPDX-License-Identifier: MIT | |
# SPDX-FileCopyrightText: 2018 Ben Siraphob <bensiraphob@gmail.com> | |
command -v gshuf >/dev/null 2>&1 || { echo >&2 "gshuf is required but is not installed. Run \"brew install coreutils\"."; control_c; } | |
command -v spoof-mac >/dev/null 2>&1 || { echo >&2 "spoof-mac is required but is not installed. Run \"brew install spoof-mac\"."; control_c; } | |
# Colors | |
RED='\033[0;31m' | |
NC='\033[0m' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createScrollManager = function() { | |
let callbacks = []; | |
let scrollPosition = -1; | |
let animatedKilled = false; | |
const animate = () => { | |
requestAnimationFrame(onScroll); | |
} | |
function onScroll(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# TODO: Need to figure out the settings for the following: | |
# 1) Dock: Items with order (not capturing binary data - since that is dependent on installed apps) | |
# 2) Security & Privacy Preferences: Full Disk Access, Camera, Microphone | |
# 3) Login items for my user (i.e. apps started when I login) | |
# 4) Retina displays scaling | |
# 5) Finder sidebar with order | |
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(fetchAndCheckPassword(event.request)) | |
}) | |
async function fetchAndCheckPassword(req) { | |
if (req.method == "POST") { | |
try { | |
const post = await req.formData(); | |
const pwd = post.get('password') | |
const enc = new TextEncoder("utf-8").encode(pwd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
total = Input.cart.subtotal_price_was | |
# spend more than $150 earns 25% off | |
if total > Money.new(cents:100) * 150 | |
discount = 0.25 | |
message = "25% Off" | |
# spend between $50 and $150 earns 20% off | |
elsif total > Money.new(cents:100) * 50 | |
discount = 0.20 | |
message = "20% Off" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eou pipefail | |
# From https://heyfocus.com/enabling-do-not-disturb-mode and | |
# https://apple.stackexchange.com/questions/145487 | |
if [[ $(defaults -currentHost read ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb) -eq 0 ]]; then | |
defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean true | |
defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturbDate -date "`date -u +\"%Y-%m-%d %H:%M:%S +000\"`" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cStringIO | |
import PIL.Image | |
from ssim import compute_ssim | |
def get_ssim_at_quality(photo, quality): | |
"""Return the ssim for this JPEG image saved at the specified quality""" | |
ssim_photo = cStringIO.StringIO() | |
# optimize is omitted here as it doesn't affect | |
# quality but requires additional memory and cpu |
NewerOlder