Skip to content

Instantly share code, notes, and snippets.

@espio999
espio999 / Roto.js
Last active March 3, 2026 06:15
OOP in JavaScript
class BasicRole {
constructor(name) {
if (this.constructor === BasicRole) {
throw new Error("BasicRoleは抽象クラスのため、インスタンス化できません。");
}
this.name = name;
}
attack() {
console.log(`${this.name}は攻撃した`);
<html>
<head>
<script>
let isInlineExecuted = false;
/*
let unlock = null;
let forceOpen = null;
const gate = new Promise((resolve, reject) => {
unlock = resolve;
forceOpen = reject;
console.log("main logic - start");
(async () => {
try{
if (isInlineExecuted) {
console.log("main logic - standby");
await gate;
}
}
catch(e){
@espio999
espio999 / test-memoization.html
Last active February 15, 2026 11:40
test for memoization
<html>
<head>
<meta charset="UTF-8">
<script src="fibonacci.js"></script>
<script>
function measurePerformance(label, func){
const point_start = `${label} ----- start`;
const point_finish = `${label} ----- end`;
performance.mark(point_start);
@espio999
espio999 / fibonacci.html
Created February 14, 2026 13:07
performance comparison for fibonacci.js
<html>
<head>
<meta charset="UTF-8">
<script src="fibonacci.js"></script>
<script>
function measurePerformance(label, func){
const point_start = `${label} ----- start`;
const point_finish = `${label} ----- end`;
@espio999
espio999 / fibonacci.js
Last active February 15, 2026 11:33
Fibonacci in JavaScript
/*function memoization(func){
let memo = new Map();
console.log(`counter: ${memo.size}`);
function memoize(arg){
console.log(`${arg} is received`);
let isExist = memo.get(arg);
if (isExist) {
return isExist;
@espio999
espio999 / memoization.fsx
Created July 23, 2024 15:20
F# memoization module
module memoization
open System.Collections.Generic
open System.Collections.Concurrent
let memoization fn =
let cache = new Dictionary<_,_>()
printfn "counter: %A" cache.Count
fun arg ->
@espio999
espio999 / comparison.fsx
Created July 22, 2024 13:11
Performance comparison of Fibonacci number in F#
#load "fibonacci.fsx"
open fibonacci
open System.Diagnostics
let loop_start = 0
let loop_end = 40
let testloop fn =
let sw = new Stopwatch()
@espio999
espio999 / fibonacci.fsx
Last active July 22, 2024 13:02
F# fibonacci module
module fibonacci
open System.Collections.Generic
let rec fib n =
match n with
| 0 | 1 -> n
| n -> fib (n-1) + fib (n-2)
[<TailCall>]
@espio999
espio999 / pattern_matching_with_type_test.fsx
Created July 1, 2024 12:46
F# pattern matching - type test
type A() = class end
type B() = inherit A()
type C() = inherit A()
let evaluation (obj: A) =
match obj with
| :? B -> "It's a B"
| :? C -> "It's a C"
| :? A -> "It's a A"
| _ -> "nothing"