Skip to content

Instantly share code, notes, and snippets.

@mizar
mizar / fetchgithub
Created October 25, 2009 07:44
github fork repos fetch
#!/usr/bin/env perl
die "remote.origin.url is not a github repos\n"
unless `git config --get remote.origin.url` =~
m{^(?:(http|git)://github\.com/|git\@github\.com\:)([\w-]+)/([\w-]+)(?:\.git)?\s*$};
my ($schema, $orguser, $orgproj) = (($1 || 'git'), $2, $3);
my %mem =
map m{<a href="/([\w-]+)/([\w-]+)">}g,
grep m{<div class="repo">},
split "\n",
`curl -s http://github.com/$orguser/$orgproj/network/members`;
@mizar
mizar / mayodice.rb
Created July 18, 2011 01:11
迷宮キングダム ダイス確率計算
#!ruby
# -*- encoding: utf-8 -*-
# 迷宮キングダム(まよキン) ダイス確率表
# N個の6面ダイス(Nd6)を振った場合に、高い方から順に出目2つを選んだものの和の値が出る確率
# ダイス [パターン総数] [期待値]
## 目標値 出現数 成功数 出現率 成功率
# 2d6 [pattern: 36] [mean: 7.000000]
## 2 1 36 2.7777777777777777777777777777778% 100.0000000000000000000000000000000%
## 3 2 35 5.5555555555555555555555555555556% 97.2222222222222222222222222222222%
mizar@mizar-VirtualBox:~$ jruby-head -v -e 'require "yaml"; p YAML.load "\u{20ac}0-"'
jruby 1.7.0.dev (ruby-1.9.3-p28) (2012-02-10 df0de38) (OpenJDK 64-Bit Server VM 1.7.0_147-icedtea) [linux-amd64-java]
UTF8Encoding.java:35:in `length': java.lang.ArrayIndexOutOfBoundsException: 5
from Matcher.java:124:in `forwardSearchRange'
from Matcher.java:432:in `search'
from RubyRegexp.java:1618:in `search19'
from RubyRegexp.java:1457:in `eqq19'
from RubyRegexp$INVOKER$i$1$0$eqq19.gen:65535:in `call'
from CachingCallSite.java:312:in `cacheAndCall'
from CachingCallSite.java:169:in `call'
@mizar
mizar / gist:1861821
Created February 19, 2012 03:34
update rvm jruby master-head/release-head
#!/bin/bash
rvm get head
rvm reinstall jruby-head
rvm cleanup sources
rvm reinstall jruby-1.6-head --branch jruby-1_6
rvm cleanup sources
Index: module/Auto/FetchTitle.pm
===================================================================
--- module/Auto/FetchTitle.pm (revision 39278)
+++ module/Auto/FetchTitle.pm (working copy)
@@ -521,7 +521,7 @@
my $anchor;
($url, $anchor) = split(/#/, $url, 2);
my $recv_limit = $this->config->recv_limit || $DEFAULT_RECV_LIMIT;
- $this->_debug($full_ch_name, "recv_limit: $recv_limit");
+ $DEBUG and $this->_debug($full_ch_name, "recv_limit: $recv_limit");
@mizar
mizar / toom_mat.rb
Last active October 6, 2015 14:07
Toom-Cook用の係数行列の例. http://xn--w6q13e505b.jp/method/toomcook.html においてToom-4の係数が一部間違っているので検算. https://drive.google.com/file/d/0B7v2yL5QFp_gVzJLVkxCMkxMeXM/view?usp=sharing
require "matrix"
def BaseWrap(x)
[[1, 0]] + x.reverse.map(&:to_r).map{|e| [e.numerator, e.denominator] }
end
def GenBase(t)
l = t * 2 - 2
x = [0, -1, 1]
0.upto(l) do |i|
break if x.size >= l
b = 2 << i
@mizar
mizar / prime_scan.gp
Last active January 9, 2023 07:02
整数環FFT用素数探索 (PARI/GP script)
hex(n) =
{
return(if(n < 0, Strprintf("-0x%x", -n), Strprintf("0x%x", n)));
};
ban(n) =
{
local(b, c, v);
c = round(n);
v = "";
while(c != 0,
@mizar
mizar / YaneuraOu-2017-early-avx2.log
Created May 31, 2017 09:54
build error log: msys2 clang avx2-lto
V:/msys64/mingw64/bin/mingw32-make -f Makefile.clang CFLAGS='-std=c++14 -fno-exceptions -fno-rtti -Wextra -Ofast -MMD -MP -fpermissive -DNO_EXCEPTIONS -stdlib=libstdc++ -DUNICODE -DNDEBUG -DUSE_MAKEFILE -DYANEURAOU_2017_EARLY_ENGINE -DUSE_AVX2 -mbmi2 -mavx2 -march=corei7-avx' LDFLAGS='-lpthread -Wl,-s -Wl,--stack,100000000 -flto' YaneuraOu-by-gcc.exe
mingw32-make[1]: Entering directory 'V:/git/YaneuraOu/source'
clang++ -std=c++14 -fno-exceptions -fno-rtti -Wextra -Ofast -MMD -MP -fpermissive -DNO_EXCEPTIONS -stdlib=libstdc++ -DUNICODE -DNDEBUG -DUSE_MAKEFILE -DYANEURAOU_2017_EARLY_ENGINE -DUSE_AVX2 -mbmi2 -mavx2 -march=corei7-avx -o ../obj/shogi.o -c shogi.cpp
In file included from shogi.cpp:4:
In file included from ./extra/../shogi.h:1019:
./extra/macros.h:79:1: warning: unused parameter 'x' [-Wunused-parameter]
ENABLE_RANGE_OPERATORS_ON(Square, SQ_ZERO, SQ_NB)
^
./extra/macros.h:76:20: note: expanded from macro 'ENABLE_RANGE_OPERATORS_ON'
inline X begin(X x) { return ZERO; } \
要望=(U)不明/(I)インストール/(R)削除/(P)完全削除/(H)保持
| 状態=(N)無/(I)インストール済/(C)設定/(U)展開/(F)設定失敗/(H)半インストール/(W)トリガ待ち/(T)トリガ保留
|/ エラー?=(空欄)無/(R)要再インストール (状態,エラーの大文字=異常)
||/ 名前 バージョン アーキテクチ 説明
+++-================================-==========================================-============-===============================================================================
ii accountsservice 0.6.40-2ubuntu11.3 amd64 query and manipulate user account information
ii acl 2.2.52-3 amd64 Access control list utilities
ii acpid 1:2.0.26-1ubuntu2 amd64 Advanced Configuration and Power Interface event daemon
ii adduser 3.113+nmu3ubuntu4 all add and remove users and groups
ii apparmor 2.10.95-0ubuntu2.6 a
@mizar
mizar / beta_cdf.py
Created July 23, 2017 02:03
正則化不完全ベータ関数 regularized incomplete beta function
import math
import numpy as np
from scipy.stats import beta
import sys
args = sys.argv
# 正則化不完全ベータ関数 regularized incomplete beta function
# 0 <= z <= 1, int(a) > 0, int(b) > 0
# beta.cdf(0,a,b) == 0
# beta.cdf(1,a,b) == 1