Skip to content

Instantly share code, notes, and snippets.

View PickledChair's full-sized avatar

Gray Suitcase PickledChair

View GitHub Profile
@PickledChair
PickledChair / type_reconstruction.rb
Last active January 8, 2024 14:56
書籍「俺々言語にだって型推論が欲しい!」の型推論器の Ruby 実装
# frozen_string_literal: true
# 書籍「俺々言語にだって型推論が欲しい!」(https://github.com/kakkun61/type-reconstruction-book-sample-code)
# の型推論器を Ruby (3.2.2) で実装してみたものです
#
# irb 上での使い方:
#
# irb(main):001> require_relative 'oreinfer'
# => true
#
@PickledChair
PickledChair / rpn.zig
Last active August 20, 2022 04:32
Zigの練習で書いてみたRPN計算機
const std = @import("std");
const Op = enum { plus, minus, times, div };
const StackError = error{ StackOverflow, EmptyStack, DivByZero };
const stackSize: usize = 1024;
const Stack = struct {
top: usize = 0,
seq: [stackSize]i32 = [_]i32{0} ** stackSize,
@PickledChair
PickledChair / json_token.py
Last active April 27, 2022 15:05
JSONの字句解析器みたいなもの
from enum import Enum, auto
class TokenKind(Enum):
# リテラル
BOOLEAN = auto() # true または false
INTEGER = auto() # 整数値
FLOAT = auto() # 浮動小数点数値
STRING = auto() # 文字列
NULL = auto() # null
@PickledChair
PickledChair / check_lack_of_dylibs.py
Created November 12, 2021 05:15
macOSにおいて共有ライブラリが開発環境に依存しているかどうかをチェックするツール
from pathlib import Path
import sys
from typing import List, Set
from check_shlib_util import get_dylib_paths, SharedLib
base_path: Path = Path.cwd()
if len(sys.argv) >= 2:
@PickledChair
PickledChair / replace.py
Last active July 30, 2020 03:48
String replacement script for Pythonista
'''
String replacement script for Pythonista
MIT License
Copyright (c) 2020 SuitCase
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
@PickledChair
PickledChair / index.html
Last active February 20, 2020 11:34
「SICP(計算機プログラムの構造と解釈)2.2.4 例: 図形言語」の Gauche 向けのコード。HTML の Canvas 要素で線分を描画する
<!DOCTYPE html>
<html>
<head>
<title>SICP Picture Language</title>
<meta charset="utf-8">
<script src="sicp_pict.js" async></script>
</head>
<body>
<canvas id="canvas" width="400" height="400"></canvas>
</body>
import pyto_ui as ui
import sys
import urllib3
from urllib3.exceptions import InsecureRequestWarning
urllib3.disable_warnings(InsecureRequestWarning)
http = None
@PickledChair
PickledChair / fibonacci.rb
Created November 23, 2019 12:00
fibonacci recursive function for Ruby
=begin
# mruby doesn't have the even? method.
class Integer
def even?
self % 2 == 0
end
end
=end
def trcall(value)
@PickledChair
PickledChair / setting.json
Last active October 12, 2019 12:06
The script to translate sentences by using the web api created with Google Apps Script.
{
"url": "https://url.to.your.webapp",
"source": "en",
"target": "ja",
"langs": [
"en",
"ja",
"zh-cn",
"de"
]