Skip to content

Instantly share code, notes, and snippets.

View gofer's full-sized avatar

Gofer gofer

View GitHub Profile
@gofer
gofer / README.md
Created October 16, 2024 06:41
PythonのHTTPサーバーをよしなにやるスクリプト

PythonのHTTPサーバーをよしなにやるスクリプト

設定

環境変数 設定内容 既定値
PID_FILE プロセスIDを格納しておくファイルへのパス /www.pid
PORT ポート番号 80
WWW_DIR ドキュメントルート $(pwd)
@gofer
gofer / generate_id.cs
Created October 4, 2024 06:45
UUID v7をプレゼンテーション層でいい感じに扱う
using System;
using UUIDNext;
using Microsoft.AspNetCore.Authentication;
public class Program
{
private static Guid GenerateId() => Uuid.NewDatabaseFriendly(UUIDNext.Database.PostgreSql);
private static string ToControllerId(Guid id) => Base64UrlTextEncoder.Encode(id.ToByteArray(true));
@gofer
gofer / avl_tree.js
Created August 6, 2024 02:15
AVL Tree in JavaScript
class BinaryTreeNode {
constructor(value) {
this.value = value;
this.left = null;
this.right = null;
}
depth() {
let result = 0;
if (this.left) {
@gofer
gofer / queue.js
Created August 3, 2024 08:18
Queue (Ring Queue)
class QueueOverflow extends Error {}
class MyQueue {
constructor(capacity) {
this.array = [];
this.head = 0;
this.tail = 0;
this.capacity = capacity;
}
isEmpty() {
@gofer
gofer / linked_list.js
Last active August 3, 2024 08:18
Linked List
class Node {
constructor(value = null, next = null) {
this.value = value;
this.next = next;
}
}
class List {
constructor() {
this.head = null;
@gofer
gofer / bin_tree_traversal.js
Last active July 23, 2024 04:32
Binary tree traversal
const tree = {
value: 'A',
left: {
value: 'B',
left: 'D',
right: 'E',
},
right: {
value: 'C',
left: 'F',
@gofer
gofer / ModalWindowBase.xaml
Last active April 4, 2022 15:05
ModalWindowBase
<UserControl x:Class="Prism6Sample.Wpf.Common.Views.ModalWindowBase"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:local="clr-namespace:Prism6Sample.Wpf.Common.Views"
@gofer
gofer / Gemfile
Last active September 17, 2019 15:59
Yahoo!天気・災害の提供する各RSS情報のURLをいい感じにJSONにするやつ
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'irb'
gem 'nokogiri'
@gofer
gofer / range.h
Last active May 6, 2019 08:44
Range Iterator
#ifndef __RANGE_H__
#define __RANGE_H__
#include <cassert>
class NumberIterator : public std::iterator<std::bidirectional_iterator_tag, int64_t, std::ptrdiff_t, int64_t*, int64_t&>
{
private:
int64_t n, d;
@gofer
gofer / red_black_tree.sml
Created October 5, 2018 17:38
Red-Black Tree
(* MLton用 ORD_KEY signature *)
signature ORD_KEY =
sig
type ord_key
val compare : (ord_key * ord_key) -> order;
end;
(* 赤黒木のシグネチャ *)
signature RED_BLACK_TREE =
sig