Skip to content

Instantly share code, notes, and snippets.

View thecoolwinter's full-sized avatar

Khan Winter thecoolwinter

View GitHub Profile
@zacwest
zacwest / ios-font-sizes.swift
Last active November 8, 2024 02:45
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]
@jgrahamc
jgrahamc / pwnd.js
Created February 24, 2018 16:36
Cloudflare Workers that adds an "Cf-Password-Pwnd" header to a POST request indicating whether the 'password' field appears in Troy Hunt's database of pwned passwords.
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)
import Foundation
public class CodableStorage {
fileprivate init() { }
enum Directory {
case documents
case caches
case shared // Use for sharing files between containers. Eg, with an app extension.
@thecoolwinter
thecoolwinter / ExtraCodable.swift
Created March 16, 2021 21:28
Helper methods for working with Codable objects and JSON Data and dictionaries. Provides two initializers and two methods for creating a Codable object using a dictionary or a Data object. And two methods for retreiving a dictionary or Data from the Codable instance.
//
// ExtraCodable.swift
//
// Created by Khan Winter on 3/16/21.
// Copyright © 2021 WindChillMedia. All rights reserved.
//
// 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
@thecoolwinter
thecoolwinter / hide_desktop.sh
Created May 20, 2021 18:35
Quickly toggle your desktop icons with a simple script. Can also be used in an Automator script as an application.
#!/usr/bin/env zsh
previous_val=$(defaults read com.apple.finder CreateDesktop)
if [ "$previous_val" = "true" ]
then
previous_val=$(echo 'false');
else
previous_val=$(echo 'true')
fi