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
function random(min, max) { | |
return min + (Math.random() * (max - min)) | |
} | |
class Point { | |
static random(min, max) { | |
return new Point( | |
random(min, max), | |
random(min, max) | |
) |
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
# | |
# Determine the time since last commit. If branch is clean, | |
# use a neutral color, otherwise colors will vary according to time. | |
# | |
# @see https://github.com/dgp/oh-my-zsh/blob/master/themes/Soliah.zsh-theme | |
# | |
function git_time_since_commit() { | |
if git rev-parse --git-dir > /dev/null 2>&1; then | |
# Only proceed if there is actually a commit. | |
if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then |
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 fs from 'fs' | |
const words = JSON.parse(await fs.promises.readFile('words-all.json', 'utf8')) | |
const count = new Map() | |
for (const word of words) { | |
for (let i = 0; i < word.length; i++) { | |
const letter = word.charAt(i) | |
count.set(letter, (count.get(letter) ?? 0) + 1) | |
} |
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 fs from 'fs' | |
import path from 'path' | |
import canvas from 'canvas' | |
const { createCanvas, loadImage } = canvas | |
const DEG_TO_RAD = Math.PI / 180 | |
const RAD_TO_DEG = 180 / Math.PI | |
function degreesToRadians(degrees) { |
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
const fs = require('fs') | |
const path = require('path') | |
const { StringDecoder } = require('string_decoder') | |
const repl = require('repl') | |
const zlib = require('zlib') | |
const { promisify } = require('util') | |
const inflateRaw = promisify(zlib.inflateRaw) | |
const decompress = inflateRaw | |
function readTable(path) { |
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
const fs = require('fs') | |
const config = fs.readFileSync('JEDI.CFG') | |
const signature = String.fromCharCode(config.readUInt8(0)) | |
+ String.fromCharCode(config.readUInt8(1)) | |
+ String.fromCharCode(config.readUInt8(2)) | |
if (signature !== 'CFG') { | |
throw new Error('Invalid signature') | |
} |
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
const fs = require('fs') | |
const content = fs.readFileSync('DARKPILO.CFG') | |
const signature = content.slice(0, 3) | |
if (!signature.equals(Buffer.from('PCF'))) { | |
throw new Error('Invalsignature DARKPILO.CFG signature') | |
} | |
const version = content.readUInt8(3) | |
if (version !== 0x12) { |
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
const fs = require('fs') | |
const buffer = fs.readFileSync(process.argv[2]) | |
function readEntry(buffer, offset) { | |
const type = buffer.slice(offset, offset + 4).toString('ascii').replace(/\u0000+$/g, '') | |
const name = buffer.slice(offset + 4, offset + 12).toString('ascii').replace(/\u0000+$/g, '') | |
const size = buffer.readUInt32LE(offset + 12) | |
return { | |
type, | |
name, |
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
#!/bin/bash | |
if [[ $1 == "start" ]]; then | |
gource -1280x720 -s 1 -a 1 > /dev/null & | |
sleep 1 | |
gst-launch-1.0 ximagesrc xname="Gource" ! queue ! video/x-raw,framerate=30/1 ! videoconvert ! vp9enc cpu-used=5 threads=12 deadline=150000 ! webmmux ! filesink location=gource.webm > /dev/null & | |
elif [[ $1 == "stop" ]]; then | |
pkill -sigint gst-launch-1.0 | |
fi |
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
const fs = require('fs') | |
const { promisify } = require('util') | |
const readFile = promisify(fs.readFile) | |
const writeFile = promisify(fs.writeFile) | |
function readGOB2(filePath) { | |
return readFile(filePath).then((buffer) => { | |
const header = buffer.slice(0,4).toString('ascii') | |
if (header !== 'GOB\x20') { |
NewerOlder