Skip to content

Instantly share code, notes, and snippets.

View yuru4c's full-sized avatar

ゆる yuru4c

View GitHub Profile
var snap = (function (floor) {
function calc(value, step) {
return floor(value / step) * step + step;
}
return function snap(value, action, step) {
switch (action) {
case '+': return calc(value, +step);
case '-': return calc(value, -step);
}
};
@yuru4c
yuru4c / leak.html
Created July 18, 2018 05:49
メモリリーク
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>メモリリーク</title>
</head>
<body>
<p>
<big id="out">0</big> バイト<br>
<samp id="err">#text</samp>
@yuru4c
yuru4c / wolframscript.js
Created September 7, 2018 00:17
node.js からの WolframScript 簡易実行
var child_process = require('child_process');
var math = (function (command) {
var wolfram = child_process.spawn(command);
var stdin = wolfram.stdin;
function Args(expr, callback) {
this.expr = String(expr);
if (typeof callback == 'function')
this.callback = callback;
@yuru4c
yuru4c / curry.js
Created September 7, 2018 01:07
カリー化もどき
Function.prototype.curry = (function (undefined) {
function copy(args) {
var length = args.length;
var array = Array(length);
for (var i = 0; i < length; i++) array[i] = args[i];
return array;
}
function curry(length) {
var fn = this;
if (length === undefined) length = this.length;
@yuru4c
yuru4c / div.js
Last active September 19, 2018 17:21
整数分割
/*
Divide(100).into(1, 2, 3); // [17, 33, 50]
*/
function Divide(number) {
if (this instanceof Divide)
this.number = number;
else return new Divide(number);
}
Divide.prototype.into = function () {
@yuru4c
yuru4c / lazy.js
Created September 24, 2018 17:49
遅延呼び出し onscroll などの待機用
function lazy(handler, timeout, continuous) {
var self, args;
var timeoutId, intervalId;
function call() {
handler.apply(self, args);
}
function onTimeout() {
if (continuous) clearInterval(intervalId);
else call();
@yuru4c
yuru4c / KCSuspender.cmd
Created October 25, 2018 03:31
艦これ一時停止スクリプト(七四式用 要 PsSuspend)
@ECHO OFF
SET suspended="%TMP%\KCSuspended"
IF EXIST %suspended% (
DEL %suspended%
SET option=/r
) ELSE (
COPY NUL %suspended% > NUL
SET option=
@yuru4c
yuru4c / ProcThrottleMax.cmd
Created October 26, 2018 04:58
スロットリング設定 なぜか直ちに反映されず
@ECHO OFF
SET guid=f0ad9da6-d3ea-4be6-8f04-821665acce60 SUB_PROCESSOR PROCTHROTTLEMAX
SET "ac=現在の AC 電源設定のインデックス: "
FOR /F "tokens=2 delims=:" %%i IN ('POWERCFG /QUERY %guid% ^| FIND "%ac%"') DO SET /A i=%%i
ECHO %ac%%i%
ECHO.
SET /P index="最大のプロセッサの状態>"
POWERCFG /SETACVALUEINDEX %guid% %index%
@yuru4c
yuru4c / maximizeMap.js
Last active August 8, 2019 06:33
某 MAP の全体を表示させる
(function ($) {
var t = $.querySelector('.map-tiles');
var v = $.querySelector('.map-viewport');
v.style.width = t.style.width;
v.style.height = t.style.height;
$.body.innerHTML = '';
$.body.appendChild(t);
$.body.style.overflow = '';
})(document);
@yuru4c
yuru4c / template.html
Created November 3, 2018 08:03
HTML 4.01 の雛型
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja-JP">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>#text</title>