Skip to content

Instantly share code, notes, and snippets.

@ytomino
ytomino / c-alloca.ads
Last active November 4, 2020 23:52
x86_64-apple-darwin12
-- This file is translated by "headmaster" version 0.30-18d0286 (devel).
-- The original C header's license should be applied to this file.
-- All conditional-directives are expanded for the exclusive use of your
-- environment, it is not recommended to commit this file to any repository.
-------------------------------------------------------------------------------
with C.stddef;
package C.alloca is
pragma Preelaborate;
function alloca (a1 : stddef.size_t) return void_ptr;
pragma Import (C, alloca, "alloca");
@ytomino
ytomino / ansi-x6004.html
Last active December 17, 2016 18:51 — forked from ShikiOkasaka/ansi-x6004.html
ANSI/新JIS配列 (ytominoの私家版)
<!doctype html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>ANSI/新JIS 配列 (私家版)</title>
<style>
body {
margin: 4px;
font-family: sans-serif;
font-size: 14px;
with Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO;
procedure MBD is
use Ada.Strings.Wide_Wide_Unbounded;
use Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO;
function "+" (Right : Wide_Wide_String) return Unbounded_Wide_Wide_String
renames To_Unbounded_Wide_Wide_String;
x : constant array (Positive range <>) of Unbounded_Wide_Wide_String := (
+"剣士", +"侍", +"弓師", +"重装兵", +"戦士", +"聖職者", +"暗殺者",
+"魔法師");
begin
@ytomino
ytomino / drake-gdb.py
Last active March 4, 2018 21:26
My first gdb pretty-printer
# from pprint import pprint
import codecs
import unicodedata
def get_typename(val):
t = gdb.types.get_basic_type(val.type).tag
if not t: t = val.type.name
return t
def is_graphic(c):
@ytomino
ytomino / runtest.sh
Last active November 25, 2017 18:19
Run drake.testsuite
#!/bin/bash
set -e
FAILURE=0
for I in *.ad[sb] ; do
echo "==== " $I " ===="
case $I in
calendar_inline.adb)
@ytomino
ytomino / murMurHash3.ml
Created May 6, 2016 05:34
OCaml implementation of MurMurHash3
let rotate_left (left: int32) (right: int): int32 =
Int32.logor
(Int32.shift_left left right)
(Int32.shift_right_logical left (32 - right));;
let fmix32 (h: int32): int32 =
let h = Int32.logxor h (Int32.shift_right_logical h 16) in
let h = Int32.mul h 0x85ebca6bl in
let h = Int32.logxor h (Int32.shift_right_logical h 13) in
let h = Int32.mul h 0xc2b2ae35l in
@ytomino
ytomino / bad_enumwindows.dpr
Last active March 29, 2016 11:52
Bad EnumWindows. Please run it with Delphi 2007. An entry for https://parnassus.co/bad-delphi-code-the-competition/
program bad_enumwindows;
{$APPTYPE CONSOLE}
uses
Types, Windows, SysUtils;
{ EnumWindows with the magic context }
type
@ytomino
ytomino / twgdb.py
Last active March 27, 2016 02:15
Open gdb's current line with TextWrangler
import subprocess
edit = "/usr/local/bin/edit"
last_filename = None
def stop_handler(event):
global last_filename
line_info = gdb.decode_line()[1][0]
window = "--new-window"
if last_filename != None:
@ytomino
ytomino / dt.nim
Created January 12, 2016 22:16
Trying dependent types in nim
type Cell[T] = ref object
car: T
cdr: Cell[T]
type List[T, N] = distinct Cell[T]
proc makeNil[T]: List[T, range[0..0]] = nil
proc makeCons[T, N](car: T; cdr: List[T, N]): auto =
type N1 = range[0..high(N)+1]
@ytomino
ytomino / nim.plist
Last active November 18, 2022 15:48
Nim language module for BBEdit/TextWrangler
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BBEditDocumentType</key>
<string>CodelessLanguageModule</string>
<key>BBLMLanguageCode</key>
<string>Nim</string>
<key>BBLMLanguageDisplayName</key>
<string>Nim</string>