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 { serve } from "https://deno.land/[email protected]/http/server.ts"; | |
const s = serve({ port: 8000 }); | |
console.log("http://localhost:8000/"); | |
for await (const req of s) { | |
req.respond({ body: "Hell Word\n" }); | |
} |
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
#!/usr/bin/env python3 | |
# coding: utf-8 | |
from typing import List, Tuple, Union | |
def radix_sort(values: List[int]) -> List[int]: | |
""" | |
基数ソート | |
:param values: 入力値 | |
:return: ソートされた値 |
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
# coding: utf-8 | |
from typing import List | |
def bucket_sort(values: List[int]) -> List[int]: | |
""" | |
バケットソート(分布数えソート) | |
:param values: 入力値(0から9までの整数値とする) | |
:return: ソートされた値 | |
""" |
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
type json = null | boolean | number | string | JsonArray | JsonObject; | |
interface JsonArray extends Array<json> { | |
} | |
interface JsonObject { | |
[key: string]: json; | |
} |
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
export default deepTypeof; | |
/** | |
* 再帰的なtypeof; nullや配列はobject型として判定しない | |
* @param {*} value 型を調べるデータ | |
* @returns {string} 型名 | |
*/ | |
function deepTypeof(value) { | |
const typename = typeof value; |
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
exports.default = hiragana2romaji; | |
// 変換テーブル; 文字数の多いものから登録していく | |
const convtables = [ | |
{ // 3文字 | |
"っきゃ": "kkya", | |
"っきぃ": "kkyi", | |
"っきゅ": "kkyu", | |
"っきぇ": "kkye", | |
"っきょ": "kkyo", |
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
// クライアントからの接続が切れたリクエストはどうなるのっと | |
var http = require("http"); | |
function main(host, port) | |
{ | |
http.createServer(respond).listen(port, host); | |
var url = "http://" + host + ":" + port + "/"; | |
console.log("curl " + url); | |
} |
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 middleware(req, res, next) { | |
// 正常/異常を問わず、終了時に必ず呼びたい関数 | |
res.finally = (callback) => { | |
res | |
.on("close", callback) // 異常終了 | |
.on("finish", callback); // 正常終了 | |
if (res.socket.destroyed) { | |
// すでに接続が切れていた | |
callback(); | |
} |
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
export class ResourceManager { | |
constructor() { | |
this._resourceFunctionsMap = {}; | |
this._resourceSingletonMap = {}; | |
this._closeCallbacks = []; | |
this._closed = false; | |
} | |
/** | |
* リソース登録 |
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 | |
# reverse mouse scroll direction | |
function _reverse_mouse_scroll_direction() { | |
local IFS=$'\n' | |
local DEVICE_NAME=$1 | |
local PROP_NAME=$2 | |
for id in $(xinput list | grep -F "${DEVICE_NAME}" | perl -n -e'/id=(\d+)/ && print $1') |