Skip to content

Instantly share code, notes, and snippets.

View AchrafKassioui's full-sized avatar

Achraf Kassioui AchrafKassioui

View GitHub Profile
@rsms
rsms / macos-distribution.md
Last active April 21, 2025 04:05
macOS distribution — code signing, notarization, quarantine, distribution vehicles
@emin-grbo
emin-grbo / decodeOrReport.swift
Created February 13, 2024 10:39
DecodeOrReport
// Used to detect specific issue with JSON decoding
func decodeOrReport(data: Data) {
do {
let _ = try JSONDecoder().decode(WidgetResponse.self, from: data)
print("\n\n👍ALL GOOD\n\n")
} catch DecodingError.keyNotFound( let key, let context) {
print("\n\n⛔️FAILED TO DECODE\n\n")
print("could not find key \(key) in JSON: \(context.debugDescription)")
} catch DecodingError.valueNotFound( let type, let context) {
print("\n\n⛔️FAILED TO DECODE\n\n")
@overlair
overlair / Coordinate-Conversion.swift
Last active October 31, 2023 00:49
SpriteKit-Coordinate-Conversion
import SpriteKit
import SwiftUI
import Combine
enum ControlUpdate {
case tap(UITapGestureRecognizer) // print SpriteKit coordinate
case doubleTap // reset camera
case pan(UIPanGestureRecognizer) // move camera
@overlair
overlair / SwiftUI+Combine+SpriteKit-Example.swift
Last active October 29, 2023 19:33
SwiftUI+Combine+SpriteKit
import SpriteKit
import SwiftUI
import Combine
/*
SpriteKit -> SwiftUI data message
*/
enum StateUpdate {
case color(UIColor)
@overlair
overlair / ExampleUIKitGestures.swift
Created October 28, 2023 03:26
UIKit Gestures in SwiftUI
import SwiftUI
struct ExampleUIKitGestureViewA: View {
var body: some View {
Color.blue
.overlay { ExampleUIKitGestureViewRepresentableA() }
/*
can also place it behind if hits are disabled on attaching view,
or you have other views you want to receive gestures that it would block
@runys
runys / SquareGame-After.swift
Last active July 14, 2023 01:28
Example code of a simple integration between SwiftUI and SpriteKit using the delegate pattern.
import SwiftUI
import SpriteKit
protocol SquareGameLogicDelegate {
var totalScore: Int { get }
mutating func addPoint() -> Void
}
// 1. Conform the ContentView to the SquareLogicDelegate protocol
@Umity
Umity / CIFilter+Extension.swift
Created August 30, 2018 21:26 — forked from ha1f/CIFilter+Extension.swift
CIFilter+Extension.swift
//
// Created by はるふ on 2017/12/11.
// Copyright © 2017年 ha1f. All rights reserved.
//
import Foundation
import CoreImage
import AVFoundation
extension CIFilter {
@matthewreagan
matthewreagan / Perlin
Last active March 30, 2024 16:18
Perlin noise generation in Swift
// Perlin.swift
// Created by Matthew Reagan on 8/7/18.
//
// Quick implementation of the the classic Perlin noise
// generation function, useful for creating organic textures
// or terrain. Perlin noise can also be easily generated with
// Apple's GameplayKit framework, this code is mostly for
// experimentation purposes. (Disclaimer: This code is not
// optimized, nor particularly elegant, but it can be used as
// a jumping off point for writing custom noise functions.)
@nthState
nthState / marchingAnts.fsh
Created April 15, 2018 19:33
Marching Ants
/**
Drag marching ants on SKShapeNode stroke
https://stackoverflow.com/questions/16838907/drawing-marching-ants-using-directx
*/
void main() {
float w = ((int)(v_tex_coord.x + v_tex_coord.y + (u_time*4)) % 8);
gl_FragColor = (w < 4 ? vec4(1,1,1,0) : vec4(0.48,0.84,0.99,1));
}
@cferdinandi
cferdinandi / vanilla-js-plugin.js
Created June 13, 2017 00:10
My starter template for vanilla JavaScript plugins.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== 'undefined' ? global : this.window || this.global, function (root) {