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
// ClockMonitor: システム時計の大幅な変更(NTP補正・手動変更等)を検知し、イベントを発行するクラス | |
// WebAudioやperformance.now()はmonotonicな経過時間だが、絶対時刻(Date.now())はシステム時計依存でジャンプすることがある | |
// そのため、performance.timeOrigin+performance.now()で絶対時刻を計算している場合、 | |
// システム時計が変化しても自動で補正されない(ズレたままになる) | |
// このクラスは、定期的にDate.now()とperformance.timeOrigin+performance.now()の差分を監視し、 | |
// 一定以上の差分が発生した場合に"clockchange"イベントを発行することで、 | |
// 利用側がoffset等を補正できるようにする | |
class ClockMonitor extends EventTarget { | |
constructor({ threshold = 2000, interval = 1000 } = {}) { | |
super(); |
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
function functionWithTimeout(fn, timeout) { | |
const workerCode = ` | |
self.onmessage = (event) => { | |
postMessage( (${fn.toString()}).apply(null, event.data) ); | |
}; | |
`; | |
return async function (...args) { | |
return await new Promise((resolve, reject) => { | |
const worker = new Worker(URL.createObjectURL(new Blob([workerCode], { type: "application/javascript" })), { |
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
//#!node | |
const sleep = (n) => new Promise( (resolve) => setTimeout(resolve, n) ); | |
const asciichart = require('asciichart') | |
const screen = { | |
clear: function () { | |
console.log('\x1b[2J'); | |
}, |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/env ruby | |
require "hid_api" # gem install hid_api | |
require "pp" | |
COMMAND_READ_ALL = 0xf2 | |
COMMAND_VERSION = 0xf9 | |
COMMAND_READ_COUNTER = 0xe3 | |
COMMAND_INITIAL_CALIB = 0xdb | |
COMMAND_PRESS_CALIB = 0xdd | |
#COMMAND_WRITE_ALL = 0x00 |
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
#!/usr/bin/env ruby | |
require 'pp' | |
D = Struct.new(:sec, :size, :name) | |
target = ARGV.shift | |
sram = `arm-none-eabi-objdump -t '#{target}'`.chomp.split(/\n/). | |
select {|l| /\.(bss|data)|vectors/ =~ l }. |
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
#!/usr/bin/perl -w | |
# avstack.pl: AVR stack checker | |
# Copyright (C) 2013 Daniel Beer <[email protected]> | |
# | |
# Permission to use, copy, modify, and/or distribute this software for | |
# any purpose with or without fee is hereby granted, provided that the | |
# above copyright notice and this permission notice appear in all | |
# copies. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
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 SignalProcessor extends AudioWorkletProcessor { | |
constructor() { | |
super(); | |
this.buffers = []; | |
this.port.onmessage = (e) => { | |
console.log(e, this.buffers); | |
this.port.postMessage(this.buffers); | |
// this.buffers.length = 0; | |
}; | |
} |
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 a = 0; | |
for (let i = 0; i < 10000; i++) { | |
a += Math.sin(i); | |
a += Math.cos(i); | |
} |
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 n = 1e-320; | |
for (let i = 0; i < 100000; i++) { | |
n = n + 1e-320; | |
} | |
n = 1e-320; | |
for (let i = 0; i < 100000; i++) { | |
n = n - 1e-320; | |
} |
NewerOlder