Skip to content

Instantly share code, notes, and snippets.

@vanwagonet
vanwagonet / FlowStack.swift
Created March 4, 2022 20:33
Simple flow layout in SwiftUI
import SwiftUI
/// A view that arranges its children in horizontal lines
///
/// FlowStack {
/// ForEach(1..<100) { num in
/// Text(String(num))
/// .padding(8)
/// .background(Circle().fill(Color.red))
/// }
@Dragon3DGraff
Dragon3DGraff / makeAtlas.js
Last active August 30, 2023 11:44
Making atlas from several images
import {
Texture,
ImageLoader,
RGBFormat,
CanvasTexture,
} from "../build/three.module.js";
export const makeAtlas = (images, size, width, height) => {
return new Promise((resolve) => {
loadAllImages(images).then((data) =>
@buahaha
buahaha / MetalView.swift
Last active November 10, 2023 13:28
Metal API SwiftUI view
//
// Created by Szymon Błaszczyński on 26/08/2021.
//
import Foundation
import MetalKit
import SwiftUI
struct MetalView: NSViewRepresentable {
func makeCoordinator() -> Coordinator {
@akihikodaki
akihikodaki / README.en.md
Last active July 16, 2024 07:16
Linux Desktop on Apple Silicon in Practice

Linux Desktop on Apple Silicon in Practice

I bought M1 MacBook Air. It is the fastest computer I have, and I have been a GNOME/GNU/Linux user for long time. It is obvious conclusion that I need practical Linux desktop environment on Apple Silicon.

Fortunately, Linux already works on Apple Silicon/M1. But how practical is it?

  • Two native ports exist.
@GrantMeStrength
GrantMeStrength / line.swift
Last active March 17, 2024 12:19
Drawing a line between two points in SceneKit / iOS / Swift
func line(from p1: SCNVector3, to p2: SCNVector3) -> SCNNode? {
// Draw a line between two points and return it as a node
var indices = [Int32(0), Int32(1)]
let positions = [p1, p2]
let vertexSource = SCNGeometrySource(vertices: positions)
let indexData = Data(bytes: &indices, count:MemoryLayout<Int32>.size * indices.count)
let element = SCNGeometryElement(data: indexData, primitiveType: .line, primitiveCount: 1, bytesPerIndex: MemoryLayout<Int32>.size)
let line = SCNGeometry(sources: [vertexSource], elements: [element])
let lineNode = SCNNode(geometry: line)
@steven2358
steven2358 / ffmpeg.md
Last active July 13, 2024 20:20
FFmpeg cheat sheet
import { Texture, ImageLoader, DefaultLoadingManager, RGBAFormat, RGBFormat } from 'three';
function TextureAtlasLoader(manager) {
this.manager = manager || DefaultLoadingManager;
}
Object.assign(TextureAtlasLoader.prototype, {
crossOrigin: "Anonymous",
tileWidth: 16,
tileHeight: 16,
@ohbargain
ohbargain / LeakyCALayerViewController.swift
Created September 21, 2016 11:22
CALayer as SCNMaterial content leaks...
import Cocoa
import SceneKit
class ViewController: NSViewController {
@IBOutlet weak var sceneView: SCNView!
@IBOutlet weak var loadButton: NSButton!
override func viewDidLoad() {
super.viewDidLoad()
loadButton.target = self
@lucasecf
lucasecf / StreamingExample.swift
Last active February 24, 2023 23:16
Example of how to use the streaming feature of the iOS MultipeerConnectivity framework
/*
For this Gist, we have two sides: sender and receiver. The same user can be a sender and a receiver, but I will separate this
two roles to be more clear.
This gist assumes thatyou already have a MCSession created, and the peers are connected,
*/
@kristopherjohnson
kristopherjohnson / Stopwatch.swift
Last active July 13, 2022 11:24
Swift classes for calculating elapsed time, similar to .NET's System.Diagnostics.Stopwatch class
// Copyright (c) 2017 Kristopher Johnson
//
// 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:
//