Skip to content

Instantly share code, notes, and snippets.

View jakubpetrik's full-sized avatar
:octocat:

Jakub Petrík jakubpetrik

:octocat:
View GitHub Profile
@bguidolim
bguidolim / ChatCollectionViewFlowLayout.swift
Created November 9, 2019 01:59
Link Preview implementation using MessageKit
//
// ChatCollectionViewFlowLayout.swift
// Engage
//
// Created by Bruno Guidolim on 04.08.19.
// Copyright © 2019 COYO GmbH. All rights reserved.
//
import MessageKit
@michael94ellis
michael94ellis / UDPClient.swift
Created June 1, 2020 14:41
iOS 12 Network Framework UDP Client Example
import Network
import Foundation
class UDPClient {
var connection: NWConnection
var address: NWEndpoint.Host
var port: NWEndpoint.Port
@kylehughes
kylehughes / TornRectangle.swift
Last active March 31, 2025 13:21
A rectangle shape for SwiftUI that can render any edge like a torn piece of paper.
// Copyright 2021 Kyle Hughes
//
// 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 copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
// Software.
//
@HipHopHuman
HipHopHuman / incremental-game-loop.md
Last active July 5, 2025 03:05
How to make a game loop for your idle game

How do I make a game loop for my Idle Game?

Interval-Based Resource Generators

So, you want to build an idle/incremental game in JavaScript and you’ve read on the internet that setInterval is the way to go when it comes to handling resources that automatically generate over time.

You get started, you write down your setInterval function, you set it to trigger once every 1000 milliseconds, and every time it triggers, you add 1 to the player’s total resource count. Perfect. It works.

Uh-oh.

//
// UDPListener.swift
//
// Created by Michael Robert Ellis on 12/16/21.
//
import Foundation
import Network
import Combine
@pdarcey
pdarcey / SwiftData.md
Last active May 4, 2025 11:24
SwiftData storage on the Mac

SwiftData storage on the Mac

Where does SwiftData store things on the Mac?

Default Storage Location

On iOS, this directory is in the app's own storage location (app_UUID/Library/Application Support) but, on the Mac, it's a shared location in the user's Library.

By default on the Mac, SwiftData stores its model in the /~/Library/Application Support directory as default.store. (It will also add two other files, default.store-shm and default.store-wal, as the model is stored as a SQLite database, and these are these additional files are part of how SQLite works.)

@jtvargas
jtvargas / MatrixEffect.swift
Created September 9, 2024 01:24
Stress Fiddle App in SwiftUI
//
// MatrixEffect.swift
//
// Created by J.T on 9/8/24.
//
import SwiftUI
import Combine
class MatrixEffectModel: ObservableObject {
@lifeutilityapps
lifeutilityapps / StandardCopyMenu.swift
Last active April 1, 2025 12:00
A reusable SwiftUI context menu component for programmatically creating a menu of user-copiable values
//
// StandardCopyMenu.swift
// DownPay for iOS
// lifeutilityapps.com/downpay
//
// Created by Life Utility Apps on 12/15/24.
//
import SwiftUI