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
/* parallelize: reads commands from stdin and executes them in parallel. | |
The sole argument is the number of simultaneous processes (optional) to | |
run. If omitted, the number of logical CPUs available will be used. | |
Build: gcc -pthread parallelize.c -o parallelize | |
Demo: (for i in {1..10}; do echo "echo $i ; sleep 5" ; done ) | ./parallelize | |
By Marco Arment, released into the public domain with no guarantees. |
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
// Source for the Accidental Tech Podcast (ATP) T-Shirt: | |
// http://www.marco.org/2014/04/29/atp-shirts | |
// | |
// By Marco Arment, April 28, 2014. MIT license. | |
@implementation ATPLogoView | |
- (void)drawRect:(CGRect)rectIgnored | |
{ | |
NSString *fontName = @"MyriadPro-Semibold"; |
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
<?php | |
function base64url_encode($binary_data) { return strtr(rtrim(base64_encode($binary_data), '='), '+/', '-_'); } | |
function apns_jwt_token($team_id, $key_id, $private_key_pem_str) | |
{ | |
if (! function_exists('openssl_get_md_methods') || ! in_array('sha256', openssl_get_md_methods())) throw new Exception('Requires openssl with sha256 support'); | |
$private_key = openssl_pkey_get_private($private_key_pem_str); | |
if (! $private_key) throw new Exception('Cannot decode private key'); |
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
// Sun.swift | |
// Created by Marco Arment on 1/17/21 | |
// | |
// Solar-math functions are directly translated from the NOAA Solar Calculator: | |
// https://www.esrl.noaa.gov/gmd/grad/solcalc/ | |
// | |
// This is free and unencumbered software released into the public domain. | |
// | |
// Anyone is free to copy, modify, publish, use, compile, sell, or | |
// distribute this software, either in source code form or as a compiled |
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
<?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 |
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 SwiftUI | |
extension UIColor: Identifiable { | |
public var id: String { | |
get { self.accessibilityName } | |
} | |
} | |
struct ContentView: View { |
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 | |
shopt -s nullglob | |
LOCALUSER=marco # Change this for you, obviously | |
DISABLED_FILES_DIR=/Users/$LOCALUSER/.quit-adobe | |
# Are any Adobe user-facing apps running? Assuming they begin with "Adobe ", e.g. "Adobe Audition 2022" | |
ps ax -c -o 'command=' | egrep '^Adobe ' | fgrep -v 'Adobe Desktop Service' | fgrep -v 'Adobe Installer' > /dev/null | |
if [ $? -eq 1 ] ; then |
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 SwiftUI | |
struct ContentView: View { | |
@State var numbers = [1, 2, 3, 4, 5, 6, 7, 8] | |
var body: some View { | |
Button { | |
withAnimation { | |
numbers.append(Int.random(in: 9..<99)) | |
numbers.sort() |
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 SwiftUI | |
extension Text { | |
public struct InlineSymbol { | |
public let name: String | |
public let accessibilityLabel: String | |
public let color: Color? | |
public init(name: String, accessibilityLabel: String, color: Color? = nil) { | |
self.name = name |
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 SwiftUI | |
extension View { | |
public func searchable_iOS16(text: Binding<String>, isPresented: Binding<Bool>, placement: SearchFieldPlacement) -> some View { | |
modifier(Searchable_iOS16(text: text, isPresented: isPresented, placement: placement)) | |
} | |
} | |
public struct Searchable_iOS16: ViewModifier { | |
@Binding var text: String |
OlderNewer