Skip to content

Instantly share code, notes, and snippets.

View earlgreyxxx's full-sized avatar

Kenji Nakagawa earlgreyxxx

  • Far West Kobe, Hyogo, Japan
  • 18:44 (UTC +09:00)
View GitHub Profile
/********************************************************************
// require ...
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
*********************************************************************/
public static string[] Where(string CommandName)
{
@earlgreyxxx
earlgreyxxx / object2formdata.mjs
Created November 16, 2023 04:27
convert plain object to FormData
const getType = o => Object.prototype.toString.call(o).match(/\w+/g)?.at(1);
export function plainObjectToFormData(o)
{
const isPlainObject = o => 'Object' === getType(o);
if(!isPlainObject(o) || Object.keys(o).length > 0)
return;
const fd = new FormData;
// use Cache API and cache expire 2 weeks
async function cachedFetchJson(uri,seconds)
{
const expire = seconds || (14 * 24 * 3600);
const today = Math.ceil(new Date().getTime() / 1000);
const cache = await caches.open('v1');
let response = await cache.match(uri);
if(!response || ((parseInt(response.headers.get('cache-timestamp') || -1) + expire <= today)))
{
@ECHO off
REM certbot wrapper
REM renew-sslcert [test]
REM testを指定すると、--dry-run (シミュレーション)を付けて実行します。
SETLOCAL
if "%~1"=="test" (
SET DRYRUN=--dry-run
) else (
SET DRYRUN=
)
@ECHO off
REM CERTBOT MANUAL CLEANUP AUTH HOOK
REM CERTBOTから下記環境変数がセットされてこのファイルが実行されますので、この情報を使ってFTPなどで認証ファイル削除します。
REM CERTBOT_DOMAIN : The domain being authenticated
REM CERTBOT_VALIDATION : The validation string
REM CERTBOT_TOKEN : Resource name part of the HTTP-01 challenge (HTTP-01 only)
REM CERTBOT_REMAINING_CHALLENGES : Number of challenges remaining after the current challenge
REM CERTBOT_ALL_DOMAINS : A comma-separated list of all domains challenged for the current certificate
@ECHO off
REM certbot wrapper
REM sslcert <ドメイン名> [test]
REM testを指定すると、--dry-run (シミュレーション)を付けて実行します。
SETLOCAL
if "%~1"=="" (
ECHO SSL証明書を取得するドメイン名を入力してください。
GOTO END
)
// ロード
import pdf2img from './pdf2img.js';
(($) => {
// PDFファイル選択
// --------------------------------------------------------------------------
async function onChangeFile(ev)
{
if(this.files.length <= 0)
return;
@earlgreyxxx
earlgreyxxx / pdf2img.js
Last active December 24, 2022 12:17
convert pdf to image
/****************************************************************************
* convert pdf to jpeg
*
* file: File instance (File object),
* type: output image format name (String: 'image/jpeg' or 'image/png' only)
* resolution: output resolution (INTEGER)
****************************************************************************/
import './pdfjs/build/pdf.min.js';
// おまじない。よくわからんけど、付けないとなんかエラー?がでるみたい。
/******************************************************************************
Japan Marc Dat file
******************************************************************************/
const MATERIALS = new Map([
['a','図書'],
['c','楽譜'],
['e','地図資料'],
['g','映像資料'],
/*****************************************************************************
*
* table to json
*
*****************************************************************************/
(function() {
HTMLTableElement.prototype.toJSON = toJSON;
HTMLTableElement.prototype.toArray = toArray;
function toJSON(indent,fn,headers)