Skip to content

Instantly share code, notes, and snippets.

View hkoba's full-sized avatar

Kobayasi, Hiroaki hkoba

View GitHub Profile
@yancya
yancya / 1.sql
Last active October 10, 2022 03:31
カラム名にテーブル名を含めるべきか否か考える https://twitter.com/neko314_/status/1579000770938433536?s=61&t=TGIhzWS_A0b4j3dWhxK50A
WITH teams AS (
SELECT 1 AS id
, 'yancya-club' AS name)
, members AS (
SELECT 1 AS id
, 'yancya' AS name
, 1 AS team_id)
SELECT *
@yusukebe
yusukebe / add.c
Last active August 12, 2022 22:32
Run `.wasm` from Node.js script
int add(int x, int y){
return x + y * 2;
}
@qnighy
qnighy / README.md
Last active August 28, 2022 19:37
マイグレーションしないRDBMS

マイグレーションしないRDBMSが欲しい!

課題

PostgreSQLなどの既存のRDBMSはスキーマを持つ。スキーマがあることは良いことだが、このスキーマのライフサイクルはアプリケーションコードのライフサイクルと乖離しがちで、結果として以下のような問題が発生する。

  • 特に自動化をしない場合はマイグレーションをデプロイとは別に行う必要が発生する。これにより、
    • シンプルに作業が面倒。
    • 承認フローが追加で必要になる。または、デプロイはレビューの管理下に置かれているのにマイグレーション側が適切に管理されないなどのミスマッチが起きる。
  • マイグレーション忘れ、マイグレーションのリバート忘れのリスクがある。
@hasegawayosuke
hasegawayosuke / async_rex.js
Created February 23, 2022 08:27
Asynchronous RegExp for node.js with termination
const { Worker, isMainThread, workerData, parentPort } = require('worker_threads')
if (isMainThread) {
class AsyncRex {
constructor (pattern, flags) {
if (pattern instanceof RegExp) {
this.source = pattern.source
this.flags = pattern.flags
} else if (typeof pattern === 'string') {
this.source = pattern
@qnighy
qnighy / juxtaposition-application.md
Created February 22, 2022 13:18
並置による関数適用に関する所感

並置による関数適用

並置による関数適用の善し悪しについて盛り上っているので、自分の意見を表明しておく。以下の2本立て。

  • 純粋に構文論的な議論 (構文拡張の余地を残す)
  • 意味論との関係での議論 (副作用の表示)

先に結論だけ書くと、私はどちらかといえば括弧による関数適用のほうが好みです。

そもそも並置による関数適用とは

@yusukebe
yusukebe / view.js
Last active January 27, 2022 22:53
import { Hono } from 'hono'
const slurpAsset = async (rawPath) => {
let ASSET_MANIFEST = __STATIC_CONTENT_MANIFEST
if (typeof __STATIC_CONTENT_MANIFEST === 'string') {
ASSET_MANIFEST = JSON.parse(__STATIC_CONTENT_MANIFEST)
}
let ASSET_NAMESPACE = __STATIC_CONTENT
const key = ASSET_MANIFEST[rawPath] || rawPath
const template = await ASSET_NAMESPACE.get(key, { type: 'text' })
import ts, { factory } from "typescript";
export function transformerFactory(context: ts.TransformationContext) {
function visitNode(node: ts.Node): ts.Node {
const newNode = ts.visitEachChild(node, visitNode, context);
if (
ts.isJsxOpeningElement(newNode) ||
ts.isJsxSelfClosingElement(newNode)
) {
return appendSourceMapAttribute(newNode.getSourceFile(), newNode);
@fumiyas
fumiyas / httpd.conf
Last active December 15, 2021 03:20
Apache HTTPD: Default virtualhost definition to deny access to an unexpected server name, but ACME
Alias /.well-known/acme-challenge/ /var/www/acme/.well-known/acme-challenge/
<Directory /var/www/acme/.well-known/acme-challenge>
Require all granted
</Directory>
<VirtualHost 127.0.0.1:80>
<IfModule status_module>
<Location /server-status>
Require ip 127.0.0.1 ::1
SetHandler server-status
@callmekohei
callmekohei / csvHelperWithFsharp.md
Created October 3, 2021 00:04
fsharp and CsvHelper

CsvHelper with fsharp

Enjoy!! (^_^)/

CSV

Name,Price,Color
import ts from "typescript";
type Files = { [key: string]: string };
type SourceFiles = { [key: string]: ts.SourceFile | undefined };
function getDiagnostics(rawFiles: Files, root: string[]) {
const compiledFiles: SourceFiles = {};
const options: ts.CompilerOptions = {
target: ts.ScriptTarget.ESNext,
};