- https://github.com/dewitters/MysticMine/blob/master/monorail/koon/app.py#L77
- https://github.com/GarageGames/Torque3D/blob/master/Engine/source/app/mainLoop.cpp
- https://github.com/OGRECave/ogre/blob/master/OgreMain/src/OgreRoot.cpp
- https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java
- https://github.com/zaki/irrlicht/blob/master/examples/Demo/CDemo.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension MemoryLayout where T: AnyObject { | |
/// Returns the memory address of the given instance. | |
/// - Parameter instance: The instance to inspect. | |
/// - Returns: A hex string representation of the memory address without leading zeros (e.g. `0x102f6dda0`). | |
@inline(__always) | |
public static func address(of instance: T) -> String { | |
"0x"+String(UInt(bitPattern: ObjectIdentifier(instance)), radix: 16, uppercase: false) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct RelativePointer<Pointee> { | |
var offset: Int32 | |
mutating func advanced() -> UnsafeMutablePointer<Pointee> { | |
return withUnsafePointer(to: &self) { [offset] pointer in | |
let rawPointer = UnsafeRawPointer(pointer) | |
let advanced = rawPointer.advanced(by: Int(offset)) | |
let pointer = advanced.assumingMemoryBound(to: Pointee.self) | |
return UnsafeMutablePointer(mutating: pointer) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let asciiChars = Character("A")...Character("z") | |
let allCharsAsString = String(asciiChars) | |
extension Character: Strideable { | |
public func distance(to other: Character) -> Int { | |
guard let value = self.asciiValue, let otherValue = other.asciiValue else { | |
fatalError("ASCII values are nil") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ManagedContiguousArray.swift | |
// FirebladeECS | |
// | |
// Created by Christian Treffs on 28.10.17. | |
// | |
public struct ManagedContiguousArray<Element> { | |
public typealias Index = Int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension BinaryInteger { | |
/// Provides a padded binary representation of this value (i.e. 01001001). | |
public var binaryDescription: String { | |
let str = String(self, radix: 2) | |
return String(repeatElement("0", count: (MemoryLayout<Self>.stride * 8) - str.utf8.count)) + str | |
} | |
} | |
extension OptionSet where RawValue: BinaryInteger { | |
/// Provides a padded binary representation of this value (i.e. 01001001). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rsync --archive --compress --crtimes --executability --human-readable --info=progress2 --ipv6 --partial --prune-empty-dirs --safe-links --sparse --update <SRC> <DEST> | |
- or - | |
rsync -azNE6mSu --info=progress2 --partial --safe-links <SRC> <DEST> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum CArray<T> { | |
@discardableResult | |
@_transparent | |
public static func write<C, O>(_ cArray: inout C, _ body: (UnsafeMutableBufferPointer<T>) throws -> O) rethrows -> O { | |
try withUnsafeMutablePointer(to: &cArray) { | |
try body(UnsafeMutableBufferPointer<T>(start: UnsafeMutableRawPointer($0).assumingMemoryBound(to: T.self), | |
count: (MemoryLayout<C>.stride / MemoryLayout<T>.stride))) | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AppKit | |
_ = NSApplication.shared | |
NSApp.setActivationPolicy(.regular) | |
//let delegate = AppDelegate() | |
//NSApplication.shared.delegate = delegate | |
let menubar = NSMenu() | |
let appMenuItem = NSMenuItem() |