Skip to content

Instantly share code, notes, and snippets.

View tib's full-sized avatar
🐦‍⬛
Learning Swift on the server.

Tibor Bödecs tib

🐦‍⬛
Learning Swift on the server.
View GitHub Profile
@keskinonur
keskinonur / CLAUDE_containerSec.md
Created April 5, 2026 12:36
Container Security Standards for CLAUDE.md

Container Security Standards

All container artifacts (Dockerfile, compose files, CI/CD pipeline configs) MUST follow these rules. Violations are treated as bugs.

Base Image

  • Use distroless, alpine, or -slim variants only
  • Pin versions with digest: FROM node:22-alpine@sha256:abc...
  • Multi-stage builds mandatory — no build toolchains in final image

Runtime Security

@sebsto
sebsto / helper.swift
Created April 1, 2025 17:25
MCP swift-SDK wrapper
import MCP
#if canImport(FoundationEssentials)
import FoundatioNEssentials
#else
import Foundation
#endif
public protocol MCPTool<Input, Output>: Sendable {
associatedtype Input
@ivanfioravanti
ivanfioravanti / mlx_memory.sh
Created January 4, 2025 16:42
Script to set MLX memory limits
#!/usr/bin/env bash
# Default values for percentages
DEFAULT_WIRED_LIMIT_PERCENT=85
DEFAULT_WIRED_LWM_PERCENT=75
# Read input parameters or use default values
WIRED_LIMIT_PERCENT=${1:-$DEFAULT_WIRED_LIMIT_PERCENT}
WIRED_LWM_PERCENT=${2:-$DEFAULT_WIRED_LWM_PERCENT}
@medeirosinacio
medeirosinacio / Jira Type Itens Icons.md
Last active June 11, 2025 22:38
Jira Type Itens Icons

Task Suggestion Subtask Story Spike Sales request Requirement Remove feature Question Poc

extension StringProtocol {
subscript(_ offset: Int) -> String.Element {
if offset >= 0 {
self[index(startIndex, offsetBy: offset)]
} else {
self[index(endIndex, offsetBy: offset)]
}
}
@adam-rocska
adam-rocska / operators+throwIfOptional.swift
Last active March 30, 2022 13:25
A Swift operator unwrapping & returning an optional value if it exists, while throwing an error if it doesn't.
// TODO: Depend on https://github.com/21GramConsulting/Beton instead
@brennanMKE
brennanMKE / README.md
Last active September 5, 2025 12:21
Create SSH Key on Mac for Xcode

Create SSH Key on Mac for Xcode

The docs for GitHub show a command to create a key with the ed25519 encryption method which is not allowed by Xcode. Even if you are not using the Source Control features in Xcode you will often need to use an account with GitHub when you are consuming Swift packages which are pulled from GitHub.

For SSH keys there are 4 algorithms.

  • 🚨 DSA: This is an older algorithm which is no longer supported and is superceded with more modern algorithms.
  • ⚠️ RSA: This algorithm was an improvement but it is now outdated and a more modern method should be used.
  • 👀 ECDSA: Another improvement which is dependent on your computer's ability to generate random numbers.
  • ✅ Ed25519: The most recommended public-key algorithm today which you should use with GitHub.
class FloatingPanel: NSPanel {
init(contentRect: NSRect, backing: NSWindow.BackingStoreType, defer flag: Bool) {
// Not sure if .titled does affect anything here. Kept it because I think it might help with accessibility but I did not test that.
super.init(contentRect: contentRect, styleMask: [.nonactivatingPanel, .resizable, .closable, .fullSizeContentView], backing: backing, defer: flag)
// Set this if you want the panel to remember its size/position
// self.setFrameAutosaveName("a unique name")
// Allow the pannel to be on top of almost all other windows
@DougGregor
DougGregor / parallel_map.swift
Created December 24, 2020 01:10
Swift async/await implementation of a parallel map
extension Collection {
func parallelMap<T>(
parallelism requestedParallelism: Int? = nil,
_ transform: @escaping (Element) async throws -> T
) async throws -> [T] {
let defaultParallelism = 2
let parallelism = requestedParallelism ?? defaultParallelism
let n = self.count
if n == 0 {
@jordanebelanger
jordanebelanger / Nullable.swift
Last active June 18, 2024 10:33
Codable enum that will differentiate between an explicitly null value vs the value being missing, useful for PATCH request etc
enum Nullable<T>: Codable where T: Codable {
case some(_ value: T)
case null
case undefined
init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if container.decodeNil() {
self = .null
} else {