This file contains 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 simd | |
// Interpolate a Quaternion without specifying duration, in the style of Herbert Stocker's X3D OrientationDamper: | |
// https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/sai/Followers/OrientationDamper.html | |
class OrientationDamper { | |
private(set) var isActive: Bool = false | |
private(set) var value: simd_quatf | |
private(set) var destination: simd_quatf | |
private(set) var tau: Float | |
private(set) var tolerance: Float |
This file contains 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
texassemble cube -w 1024 -h 1024 -o cubemap.dds px.jpg nx.jpg py.jpg ny.jpg pz.jpg nz.jpg | |
texconv cubemap.dds -m 0 -y -f BC1_UNORM |
This file contains 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
<!DOCTYPE HTML> | |
<html lang="en"> | |
<head> | |
<title>Record WebGL to WebM (Chrome only)</title> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="styles.css" charset="utf-8"> | |
</head> | |
<body> | |
<div class="buttons"> |
This file contains 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 mset | |
# Smarter "findMaterial": doesn't print a message in the console | |
# or throw an error when the object to find doesn't exist. | |
def getMaterial(name, createIfNotFound=False): | |
found = None | |
objs = mset.getAllMaterials() | |
for obj in objs: | |
if obj.name == name: | |
found = obj |
This file contains 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
'use strict'; | |
const {readFileSync} = require('fs'); | |
const {createServer} = require('http'); | |
const {EventEmitter} = require('events'); | |
let bufferIndex = -1; | |
const buffers = [ | |
readFileSync('1.jpg'), | |
readFileSync('2.jpg'), | |
readFileSync('3.jpg'), |
This file contains 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
/* eslint-env browser */ | |
import type {IRequestWorker} from "./worker.ts"; | |
const worker = new Worker(new URL("./worker.ts", import.meta.url)) as IRequestWorker; | |
// Receive from the worker | |
worker.onmessage = ({data: {myresponse}}) => { | |
console.log(myresponse); | |
}; |
This file contains 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
FROM ubuntu:22.04 | |
RUN apt update \ | |
&& apt install -y wget \ | |
&& wget https://github.com/digitalocean/doctl/releases/download/v1.88.0/doctl-1.88.0-linux-amd64.tar.gz -O doctl.tar.gz \ | |
&& tar xf doctl.tar.gz \ | |
&& rm doctl.tar.gz \ | |
&& mv doctl /usr/local/bin |
This file contains 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
// CSS gradient generated by https://www.joshwcomeau.com/gradient-generator/ | |
// hsl(199deg 95% 55%) 0% | |
// hsl(140deg 63% 65%) 50% | |
// hsl(99deg 100% 50%) 100% | |
let gradient = CAGradientLayer() | |
// ... | |
gradient.type = .axial | |
gradient.colors = [ | |
UIColor.hsl(degrees: 199, saturation: 0.95, lightness: 0.55).cgColor, |
This file contains 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 Foundation | |
class JSON { | |
static func encodeData<T>(_ from: T, format: JSONEncoder.OutputFormatting = .sortedKeys) -> Data? where T: Encodable { | |
let encoder = JSONEncoder() | |
encoder.outputFormatting = format | |
do { | |
return try encoder.encode(from) | |
} catch { | |
print(error) |
This file contains 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 Foundation | |
extension FileManager { | |
public static var documentDirectory: URL { | |
return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! | |
} | |
} |