Skip to content

Instantly share code, notes, and snippets.

View jakubpetrik's full-sized avatar
:octocat:

Jakub Petrík jakubpetrik

:octocat:
View GitHub Profile
@pdarcey
pdarcey / SwiftData.md
Last active April 16, 2024 19:00
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.)

@HipHopHuman
HipHopHuman / incremental-game-loop.md
Last active March 27, 2024 11:56
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.

@kylehughes
kylehughes / TornRectangle.swift
Last active August 12, 2023 01:20
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.
//
@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
@mcichecki
mcichecki / CGFloat+normalization.swift
Last active June 16, 2023 08:58
Normalized value of CGFloat between two values
extension BinaryFloatingPoint {
/// Returns normalized value for the range between `a` and `b`
/// - Parameters:
/// - min: minimum of the range of the measurement
/// - max: maximum of the range of the measurement
/// - a: minimum of the range of the scale
/// - b: minimum of the range of the scale
func normalize(min: Self, max: Self, from a: Self = 0, to b: Self = 1) -> Self {
(b - a) * ((self - min) / (max - min)) + a
}
@gokselkoksal
gokselkoksal / Channel.swift
Last active September 16, 2022 03:53
Channel implementation
public class Channel<Value> {
private class Subscription {
weak var object: AnyObject?
private let notifyBlock: (Value) -> Void
private let queue: DispatchQueue
var isValid: Bool {
return object != nil
@fbn4sc
fbn4sc / command.txt
Created January 29, 2018 01:35
Delete all branches except master and develop.
git branch | grep -v "master\|develop" | xargs git branch -D
Advanced Animations with UIKit
video: https://devstreaming-cdn.apple.com/videos/wwdc/2017/230lc4n1loob9/230/230_hd_advanced_animations_with_uikit.mp4?dl=1
pdf: https://devstreaming-cdn.apple.com/videos/wwdc/2017/230lc4n1loob9/230/230_advanced_animations_with_uikit.pdf
Advanced Touch Bar
video: https://devstreaming-cdn.apple.com/videos/wwdc/2017/222ijxk2akkrebmr/222/222_hd_advanced_touch_bar.mp4?dl=1
pdf: https://devstreaming-cdn.apple.com/videos/wwdc/2017/222ijxk2akkrebmr/222/222_advanced_touch_bar.pdf
Advances in TVMLKit
video: https://devstreaming-cdn.apple.com/videos/wwdc/2017/202ximbb9e2dq222/202/202_hd_advances_in_tvmlkit.mp4?dl=1
@DejanEnspyra
DejanEnspyra / Obfuscator.swift
Created May 31, 2017 17:51
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {
@huytd
huytd / .gitconfig
Created August 4, 2016 16:26
Use neovim as diff tool
[merge]
tool = vimdiff
[mergetool]
prompt = true
[mergetool "vimdiff"]
cmd = nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'
[difftool]
prompt = false
[diff]
tool = vimdiff