Skip to content

Instantly share code, notes, and snippets.

@snipsnipsnip
snipsnipsnip / cdf.ijs
Last active August 29, 2015 14:02
J言語でF分布とt分布とカイ二乗分布の累積分布関数 (CDF of χ² distribution, Student's t-distribution and F-distribution in J programming language)
NB. ガンマ関数。gamma x = Γ(x)
gamma =: ! @ <:
NB. ベータ関数。 x B y = B(x, y)
beta =: * & gamma % gamma @ +
NB. 不完全ベータ関数。a b incomplete_beta x = B(x;a,b)
NB. H.で一般化超幾何級数を求められるらしい cf. http://www.jsoftware.com/jwiki/Vocabulary/hcapdot
incomplete_beta =: dyad define
'm n' =. x
NB. Amachang's prototype-based OOP example in J
NB. http://d.hatena.ne.jp/amachang/20061019 via http://blog.livedoor.jp/dankogai/archives/50666398.html
animal =. conew 'z'
breath__animal =: verb define
echo 'すーはー'
)
NB. 鳥さんのプロトタイプ
NB. SELF's BankAccount example in J
NB. http://sumim.no-ip.com/wiki/849
bankAccount =. conew 'z'
dollars__bankAccount =: 200
NB. Not present in the original code. Defined a getter to make it customizable.
getDollars__bankAccount =: verb define
dollars
@snipsnipsnip
snipsnipsnip / attr.ijs
Created June 14, 2014 17:43
attr_reader, attr_writer and attr_accessor in J
coclass 'attr'
attr_reader =: monad define
loc =. > coname ''
names =. ;: y
dup =. ((# names) & $) & <
fullnames =. names ,. dup ('_' , loc , '_')
". joinstring"1 (dup 'get_') ,. fullnames ,. (dup '=: 3 : ''') ,. names ,. (dup '''')
)
@snipsnipsnip
snipsnipsnip / name_value_table.ijs
Created June 18, 2014 03:27
name_value_table.ijs: Hashのようなもの
coclass 'NameValueTable'
PREFIX =: 'ENTRY'
NB. =: Indirectly Used Copula. http://www.jsoftware.com/help/dictionary/d001.htm
set =: dyad define
(PREFIX , x) =: y
)
NB. ~ as Evoke. http://www.jsoftware.com/help/dictionary/d220n.htm
@snipsnipsnip
snipsnipsnip / example.txt
Last active August 29, 2015 14:04
lvbar.rb is a `pvs` wrapper that shows allocation status of LVM logical volumes in bar chart
$ sudo ruby lvbar.rb
/dev/sda0
[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb]
a: vg_foo/lv_bar (54%)
b: (unallocated) (46%)
/dev/sda1
[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]
a: vg_foo/lv_baz (100%)
@snipsnipsnip
snipsnipsnip / lookup-inode.sh
Last active August 29, 2015 14:06
lookup-inode.sh: inode番号からディレクトリ名を逆引き
#!/bin/sh
# taken from http://unix.stackexchange.com/questions/35292/quickly-find-which-files-belongs-to-a-specific-inode-number
if [ "$1" ] && [ "$2" ]; then
exec sudo debugfs -R "ncheck $2" "$1" 2> /dev/null
else
echo "usage: $0 device inode-number"
fi
@snipsnipsnip
snipsnipsnip / amalgamator.py
Last active August 29, 2015 14:10
amalgamator.py (混汞器): #include-only dumb C Preprocessor
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# MIT License. @snipsnipsnip
"""
混汞器/アマルガメータ (Konkohki/amalgamator): #include-only dumb C Preprocessor
Sqliteのamalgamationみたいなことをするツール。
(本家を見るなら tool/mksqlite3c.tcl 参照)
つまり、#includeだけを部分的に実行するCプリプロセッサ。
@snipsnipsnip
snipsnipsnip / tell-x86-or-x64.bat
Created January 7, 2015 18:29
tell-x86-or-x64.bat
@if "%PROCESSOR_ARCHITECTURE%%PROCESSOR_ARCHITEW6432%" EQU "x86" (
@echo truly x86
) else (
@echo x64
)
@snipsnipsnip
snipsnipsnip / print-8.3-name.bat
Created January 12, 2015 19:16
print-8.3-name.bat
@echo %~s1