Skip to content

Instantly share code, notes, and snippets.

@miura1729
miura1729 / mhash.c
Created September 24, 2023 02:26
can 64 entry in 64bucket
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
typedef int key_t;
typedef int value_t;
typedef struct mhash {
uint64_t exists;
uint64_t origin;
@miura1729
miura1729 / mhash.c
Last active September 23, 2023 11:47
1st version 24 entry on 32 buckets
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
typedef int key_t;
typedef int value_t;
typedef struct mhash {
uint64_t exists;
uint64_t origin;
def ast2str(node)
case node.type
when :SCOPE
tbl, args, body = node.children
"(#{tbl.map {|e| e.to_s}.join(" ,")}) \n #{ast2str(body)}"
when :ARGS
p node.children[1]
p node.children
"()"
main() {
printf("%d\n ", mod5(1));
printf("%d\n ", mod5(2));
printf("%d\n ", mod5(3));
printf("%d\n ", mod5(4));
printf("%d\n ", mod5(5));
printf("%d\n ", mod5(11));
printf("%d\n ", mod5(32));
printf("%d\n ", mod5(10));
printf("%d\n ", mod5(15));
@miura1729
miura1729 / gp.rb
Last active February 17, 2022 11:39
  graph TD
    N2[5]
    N1[ARRAY] --> |0| N2
    N3["foo"]
    N1[ARRAY] --> |1| N3
    N4[:a]
    N1[ARRAY] --> |2| N4
    N0[Foo] --> |"@a"| N1
 N0[Foo] --&gt; |"@b"| N0
Literal NilClass|
Literal FalseClass|Literal TrueClass|
Fixnum e=false pos =true|Float e=false pos =false|
String e=true l=8 var=0|
Array<[:undef] => Literal NilClass|[:undef] => Literal FalseClass|[:undef] => Literal TrueClass|
  [:undef] => Fixnum e=false pos =true|[:undef] => Float e=false pos =false|[:undef] => String e=true l=8 var=0|
 1 => Literal NilClass|1 => Literal FalseClass|1 => Literal TrueClass|1 => Fixnum e=false pos =true|
1 => Float e=false pos =false|1 => String e=true l=8 var=0> e=true l=8|Hash<[:undef] => NilClass e=false l=0 var=0|
[:undef] => Literal FalseClass|[:undef] => Literal TrueClass|[:undef] => Fixnum e=false pos =true|
[:undef] => Float e=false pos =false|[:undef] => String e=true l=8 var=0|
#include <mruby.h>
#include <mruby/value.h>
#include <mruby/array.h>
#include <mruby/hash.h>
#include <mruby/throw.h>
#include <mruby/proc.h>
#include <mruby/string.h>
#include <mruby/range.h>
#include <mruby/error.h>
#include <mruby/variable.h>
@miura1729
miura1729 / BCD
Last active December 15, 2020 08:34
def add(x, y)
hc = ((x & 0x0f0f0f0f) + (y & 0x0f0f0f0f)) & 0xf0f0f0f0
hc |= (((x & 0xf0f0f0f0) + (y & 0xf0f0f0f0)) & 0xf0f0f0f0f)
c = x + y
if c & 0xf > 0x9 or hc & 0x10 != 0 then
c = c - 0xa + 0x10
end
if c & 0xf0 > 0x90 or hc & 0x100 != 0 then
c = c - 0xa0 + 0x100
end
#!/usr/local/bin/ruby -d -Ks
# -*- mode: ruby; tab-width: 2; -*-
require 'win32ole'
require 'delegate'
require 'singleton'
module ExcelConsts
end
class TheExcel<SimpleDelegator
@miura1729
miura1729 / chunk.rb
Created November 3, 2020 22:30
SMAF
# SMAF operation class
# Copyright (c) 2002 Hideki MIURA
# You can redistribute it and/or modify it under the same term as Ruby.
#
# Copyright of SMAF belonges to YAMAHA Corpration
#
module SMAF
# Block base class