Skip to content

Instantly share code, notes, and snippets.

View MaximKotliar's full-sized avatar
🚲
Педалю ровери

Maxim Kotliar MaximKotliar

🚲
Педалю ровери
View GitHub Profile

How to install game-porting-toolkit (aka proton for macOS)

You also might wanna just use Whisky which does this automatically

This guide works on macOS 13.4+ using Command Line Tools for XCode 15 Beta!

What is this?

In the recent WWDC, Apple announced and released the "game porting toolkit", which upon further inspection this is just a modified version of CrossOver's fork of wine which is a "compatibility layer" that allows you to run Windows applications on macOS and Linux.

extension Task where Failure == Error {
// Start a new Task with a timeout. If the timeout expires before the operation is
// completed then the task is cancelled and an error is thrown.
init(priority: TaskPriority? = nil, timeout: TimeInterval, operation: @escaping @Sendable () async throws -> Success) {
self = Task(priority: priority) {
try await withThrowingTaskGroup(of: Success.self) { group -> Success in
group.addTask(operation: operation)
group.addTask {
try await _Concurrency.Task.sleep(nanoseconds: UInt64(timeout * 1_000_000_000))
@Snowy1803
Snowy1803 / ContentView.swift
Last active July 28, 2023 01:37
This code allows you to use matchedGeometryEffect in SwiftUI while keeping iOS 13 compatibility in your app.
//
// ContentView.swift
// Example of using matchedGeometryEffect in iOS 13 code
// matchedGeometryEffect example code taken and adapted from :
// https://sarunw.com/posts/a-first-look-at-matchedgeometryeffect/
//
// Created by Emil Pedersen on 16/10/2020.
//
struct ContentView: View {
import Foundation
// MARK: - Interval
struct Interval {
var low: Int
var high: Int
func overlaps(_ otherInterval: Interval) -> Bool {
return contains(otherInterval.low) || contains(otherInterval.high)
}
@RuiAAPeres
RuiAAPeres / SwiftUIBindsWithReactiveSwift.swift
Last active December 12, 2023 09:30
Couple of methods to bridge ReactiveSwift with SwiftUI
import Combine
import ReactiveSwift
import SwiftUI
class AnySubscription: Subscription {
private let cancelable: Cancellable
init(cancelable: Cancellable) {
self.cancelable = cancelable
@omarojo
omarojo / VideoMediaInput.swift
Last active May 13, 2024 06:35
How to use MTAudioProcessingTap in Swift 4.2
//
// VideoMediaInput.swift
// GenerateMetal-iOS
//
// Created by Omar Juarez Ortiz on 2018-11-28.
// Copyright © 2018 All rights reserved.
//
import Foundation
import UIKit
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active June 27, 2024 10:27
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@koenrh
koenrh / gcp-gpu-vm-hashcat.md
Last active June 14, 2024 17:37
Running Hashcat on Google Cloud's new GPU-based VMs

Running Hashcat on Google Cloud's GPU-based VMs

In February 2017, Google announced the availability GPU-based VMs. I spun up a few of these instances, and ran some benchmarks. Along the way, I wrote down the steps taken to provision these VM instances, and install relevant drivers.

Update April 2019: Updated instructions to use instances with the Tesla T4 GPUs.

@DavidBoyes
DavidBoyes / gist:5290376
Created April 2, 2013 06:48
Returns a rectangle which is the largest that can fit inside a rotated rectangle
- (CGRect)cropRectForRectSize:(CGSize)rectSize rotation:(float)radians {
int quadrant = ((int)floor(radians / (M_PI / 2))) & 3;
float sign_alpha = ((quadrant & 1) == 0) ? radians : M_PI - radians;
float alpha = fmod((fmod(sign_alpha, M_PI) + M_PI), M_PI);
CGSize bb = CGSizeMake(rectSize.width * cos(alpha) + rectSize.height * sin(alpha), rectSize.width * sin(alpha) + rectSize.height * cos(alpha));
float gamma = rectSize.width < rectSize.height ? atan2(bb.width, bb.height) : atan2(bb.height, bb.width);
float delta = M_PI - alpha - gamma;
float length = rectSize.width < rectSize.height ? rectSize.height : rectSize.width;
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",