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 std.traits; | |
To quantize(To, From)(From val) | |
if(isFloatingPoint!From && isIntegral!To && isSigned!To) | |
in(val >= -1.0 && val <= 1.0) | |
{ | |
return cast(To)( | |
(To.max - To.min) // unsigned equivalent's .max | |
* ((val + 1) / 2) // val from [-1.0, 1.0] -> [0.0, 1.0] | |
+ To.min // shift back into signed value range |
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
/++dub.sdl: | |
name "dnstest" | |
versions "VibeDefaultMain" | |
dependency "vibe-core" version="~>1.9.3" | |
+/ | |
import std.socket: AddressFamily; |
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
# Maintainer: Sanpi <[email protected]> | |
pkgname=emsdk | |
pkgver=1.35 | |
pkgrel=6 | |
pkgdesc='The Emscripten SDK' | |
arch=('x86_64') | |
url='https://kripken.github.io/emscripten-site/' | |
license=('MIT') | |
depends=('python2' 'cmake') | |
source=("https://github.com/emscripten-core/emsdk/archive/master.zip" |
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
class AsyncWebSocket | |
{ | |
constructor() | |
{ | |
this.socket = null; | |
this.resolvers = []; | |
} | |
connect(remote) | |
{ |
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 gfm.math; | |
Vec project(Vec: Vector!(T, N), T, size_t N)(Vec a, Vec b) | |
{ | |
return b * scalarProject(a, b); | |
} | |
T scalarProject(Vec: Vector!(T, N), T, size_t N)(Vec a, Vec b) | |
{ | |
import std.math: cos; |
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 std.traits; | |
Type construct(Type)(RepresentationTypeTuple!Type args) | |
{ | |
static union Conv | |
{ | |
Type obj; | |
struct { typeof(args) fields; } | |
} | |
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
const fs = require("fs"); | |
module.exports = function(source) | |
{ | |
const buffer = fs.readFileSync(this.resourcePath) | |
return `module.exports = Uint8Array.from([${buffer.toJSON().data}]);`; | |
} |
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
const chunks = ( | |
(array, size) => | |
Array.from( | |
Array(array.length / size), | |
(_, x) => | |
Array.from( | |
Array(size), | |
(_, y) => array[size * x + y] | |
) | |
) |
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
const cache = {}; | |
const queue = []; | |
export function enqueueImage(path) | |
{ | |
if(cache.hasOwnProperty(path)) | |
return; | |
queue.push(path); | |
} |
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
string[] shlex(string line) | |
{ | |
string[] result; | |
string current; | |
char quoteChr = 0; | |
bool escape; | |
foreach(chr; line) | |
{ | |
switch(chr) |