Skip to content

Instantly share code, notes, and snippets.

View jkaunert's full-sized avatar

Joshua Kaunert jkaunert

View GitHub Profile
// Just create a project for iOS 17 and put it in ContentView.swift
struct ContentView: View {
@State var colors : [Color] = [.blue, .red, .green, .yellow, .brown, .mint, .indigo, .pink, .teal]
var body: some View {
NavigationStack{
ScrollView(.vertical){
VStack(items: colors){ color in
@DougGregor
DougGregor / macros.md
Last active October 24, 2023 16:42
A possible vision for macros in Swift

A Possible Vision for Macros in Swift

As Swift evolves, it gains new language features and capabilities. There are different categories of features: some fill in gaps, taking existing syntax that is not permitted and giving it a semantics that fit well with the existing language, with features like conditional conformance or allowing existential values for protocols with Self or associated type requirements. Others introduce new capabilities or paradigms to the language, such as the addition of concurrency or comprehensive reflection.

There is another large category of language features that provide syntactic sugar to eliminate common boilerplate, taking something that can be written out in long-form and making it more concise. Such features don't technically add any expressive power to the language, because you can always write the long-form version, but their effect can be transformational if it enables use cases that would otherwise have been unwieldy. The synthesis of Codable conformances, for ex

@jordansinger
jordansinger / AppleLogo.swift
Created June 16, 2021 18:37
Original Apple logo in SwiftUI
import SwiftUI
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
Color.green
Color.green
Color.green
Color.yellow
Color.orange
@import Darwin;
@import ObjectiveC;
@import CloudKit;
extern bool GEOConfigGetBOOL(int feature, void* something);
// Hooks feature flags in a resigned Maps.app to return true.
// Usage:
// clang -shared -fmodules -o libmaps_inject.dylib maps_inject.m \
// "$(xcrun
import Foundation
public protocol JSONEncodable: Encodable {
static var keyEncodingStrategy: JSONEncoder.KeyEncodingStrategy { get }
static var dateEncodingStrategy: JSONEncoder.DateEncodingStrategy { get }
static var dataEncodingStrategy: JSONEncoder.DataEncodingStrategy { get }
static var nonConformingFloatEncodingStrategy: JSONEncoder.NonConformingFloatEncodingStrategy { get }
func toJSON() throws -> Data
}
@junebash
junebash / CGExtensions.swift
Last active August 21, 2020 15:20
CGContext + Add Curved Polygon (+ vector helper methods) — Core Graphics extensions
//
// CGExtensions.swift
//
// Created by Jon Bash on 2019-11-06.
// Copyright © 2019 Jon Bash. 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
@davedelong
davedelong / NSLocale.m
Last active October 15, 2022 08:02
Locales
/*
======================================================
THIS CODE IS FOR EDUCATIONAL PURPOSES ONLY.
I'M NOT RESPONSIBLE IF YOU SHIP THIS AND IT BLOWS UP IN YOUR FACE.
IF IT DOES AND YOU COMPLAIN TO ME I WILL LAUGH AT YOU.
@cprovatas
cprovatas / Data+PrettyPrint.swift
Created May 23, 2018 15:52
Pretty print JSON string from Data in Swift 4.1 (especially useful printing to Xcode console)
import Foundation
extension Data {
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription
guard let object = try? JSONSerialization.jsonObject(with: self, options: []),
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]),
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil }
return prettyPrintedString
}
@peterjaap
peterjaap / packit4me.php
Last active June 4, 2021 03:08
Packit4me 3d viz
<?php
$url = "http://www.packit4me.com/api/call/raw";
$previewUrl = "http://www.packit4me.com/api/call/preview";
$bin = [
'id' => 0,
'maxweight' => 50,
'dimensions' => '5x5x5'
];
@schmich
schmich / ducky.md
Last active July 10, 2024 10:25
Programming media keys on the Ducky One 2 Skyline

Programming Media Keys on the Ducky One 2 Skyline

To use media keys on the Ducky One 2 Skyline, you must record a macro to bind the media function to a hotkey combination, i.e. Fn plus some key.

Example

Important: In the instructions below, "Press X+Y+Z" means press and hold key X, press and hold key Y, press and hold key Z in that order, and then release all three.

As an example, to bind Fn+PgUp to the play/pause media function: