Skip to content

Instantly share code, notes, and snippets.

View Farini's full-sized avatar
👾
coding...

Farini Farini

👾
coding...
View GitHub Profile
@Farini
Farini / PathFinder.swift
Created August 21, 2021 17:32
SceneKit node follow NURBS path.
// Pathfinder
// Created by Carlos Farini on 8/21/21.
/**
This is a tutorial that tries to approach the following question:
How to make a `SCNNode` follow a 3D Path (with orientation) created with Blender NURBS curve.
A: Simple. Move and Point to the next object.
@Farini
Farini / NSImageExtensions.swift
Last active January 23, 2024 12:01 — forked from MaciejGad/NSImageExtensions.swift
NSImage extensions for easy resizing, cropping and saving png images. Version updated for Swift 3. Originally by Raphael Hanneken https://gist.github.com/raphaelhanneken/cb924aa280f4b9dbb480
extension NSImage {
/// Returns the height of the current image.
var height: CGFloat {
return self.size.height
}
/// Returns the width of the current image.
var width: CGFloat {
return self.size.width
@Farini
Farini / BLKTransparent.swift
Last active March 10, 2024 07:49
CIFilter with Metal shader
/**
A CIFilter that uses a Metal function that converts a black pixel (or almost black) to a transparent pixel.
*/
class BLKTransparent: CIFilter {
private var kernel: CIColorKernel
var inputImage: CIImage?
var threshold: Float?
@Farini
Farini / fileDateAttributes.swift
Last active May 24, 2021 17:12
Last modified + created date property of a file
/// Gets the Last Modified and Created Date of the file at path.
func fileDateAttributes(at path:String) -> (created:Date?, modified:Date?) {
do {
let attributes:[FileAttributeKey:Any] = try FileManager.default.attributesOfItem(atPath: path)
let modificationDate = attributes[FileAttributeKey.modificationDate] as? Date
let creationDate = attributes[FileAttributeKey.creationDate] as? Date
return (creationDate, modificationDate)
}catch{
print("Error getting attributes of file: \(path). Check if file exists and that the system can access its attributes.")
@Farini
Farini / Friends.swift
Created October 15, 2019 01:10
Friends suggestions implementation
import UIKit
// MARK: - Friends
class Person:Equatable{
static func == (lhs: Person, rhs: Person) -> Bool {
return lhs.name == rhs.name
}