TL;DR: Use var
for properties in struct
as long as it serves as a nominal tuple. In most cases, there is no obvious benefit to using let
for struct
properties.
Let's start with a simple example:
struct MyStruct {
import SQLite3 | |
import Foundation | |
func main(dbPath: String) { | |
// Pointer for database connection | |
var db: OpaquePointer? | |
// Open database | |
guard sqlite3_open(dbPath, &db) == SQLITE_OK else { | |
print("Error opening database: \(String(cString: sqlite3_errmsg(db)))") |
"use client"; | |
/* eslint-disable @next/next/no-img-element */ | |
import Link from "next/link"; | |
import { useState, useEffect } from 'react'; | |
import { | |
AppBskyFeedDefs, | |
AppBskyFeedPost, | |
type AppBskyFeedGetPostThread, | |
} from "@atproto/api"; |
Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output. | |
- Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure. | |
- Reasoning Before Conclusions: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS! | |
- Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed. | |
- Conclusion, classifications, or results should ALWAYS appear last. | |
- Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements. | |
- What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from p |
// | |
// OCXML.swift | |
// Created by Marco Arment on 9/23/24. | |
// | |
// Released into the public domain. Do whatever you'd like with this. | |
// No guarantees that it'll do anything, or do it correctly. Good luck! | |
// | |
import Foundation |
#!/usr/bin/env bash | |
PLIST=~/Library/Group\ Containers/group.com.apple.replayd/ScreenCaptureApprovals.plist | |
CURRENT_DATE=$(date +%s) | |
ONE_YEAR_FROM_NOW=$(date -v+1y +%s) | |
if [ -f "$PLIST" ]; then | |
# Contents of the plist file look like this: | |
# Dict { /Applications/1Password.app/Contents/MacOS/1Password = Sat Sep 21 11:59:57 PST 2024 /Applications/Microsoft Teams.app/Contents/MacOS/MSTeams = Tue Sep 21 05:40:36 PST 3024 /Applications/CleanShot X.app/Contents/MacOS/CleanShot X = Tue Sep 21 05:40:36 PST 3024 /Applications/Ice.app/Contents/MacOS/Ice = Sat Sep 21 05:40:36 PST 2024 /Applications/Shottr.app/Contents/MacOS/CleanShot X = Tue Sep 21 05:40:36 PST 3024 } |
{%- if messages[0]["role"] == "system" %} | |
{%- set system_message = messages[0]["content"] %} | |
{%- set messages = messages[1:] %} | |
{%- else %} | |
{%- set system_message = "" %} | |
{%- endif %} | |
{%- if not tools is defined %} | |
{%- set tools = none %} | |
{%- endif %} | |
{%- if not date_string is defined %} |
import Foundation | |
import SwiftUI | |
import UIKit | |
extension UIBlurEffect { | |
public static func variableBlurEffect(radius: Double, imageMask: UIImage) -> UIBlurEffect? { | |
let methodType = (@convention(c) (AnyClass, Selector, Double, UIImage) -> UIBlurEffect).self | |
let selectorName = ["imageMask:", "effectWithVariableBlurRadius:"].reversed().joined() | |
let selector = NSSelectorFromString(selectorName) |
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks. | |
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) | |
(() => { | |
const SHOW_SIDES = false; // color sides of DOM nodes? | |
const COLOR_SURFACE = true; // color tops of DOM nodes? | |
const COLOR_RANDOM = false; // randomise color? | |
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com) | |
const MAX_ROTATION = 180; // set to 360 to rotate all the way round | |
const THICKNESS = 20; // thickness of layers | |
const DISTANCE = 10000; // ¯\\_(ツ)_/¯ |
import UIKit | |
import MetalKit | |
class ViewController: UIViewController { | |
override func viewDidAppear(_ animated: Bool) { | |
super.viewDidAppear(animated) | |
let imageView = UIImageView(image: UIImage(named: "landscape.jpeg")) | |
imageView.frame = CGRect(x: 0, y: 200, width: 350, height: 197) | |
view.addSubview(imageView) |