Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
補間(Interpolation)
・ラグランジュ補間
・ニュートン補間
通る点
(0, 0.8), (1, 3.1), (3, 4.5), (6, 3.9), (7, 2.8)
'''
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
任意精度整数
加減
演算子オーバーロードから受けた左辺と右辺の正負と大小
から、演算結果の正負を予測し addition や subtraction
に割り振る
乗算
#!/usr/bin/python
# -*- coding: utf-8 -*-
# マチンの公式
# π /4 = 4arctan(1/5) - arctan(1/239)
# π = (16/5 - 16/(3*5^3) + 16/(5*5^5) - ...) - (4/239 - 4/(3*239^3) + ...)
# = (16/5 - 4/239) - (16/(3*5^3) - 4/(3*239^3)) + ...
# w[0] = 16/5, w[1] = w0/(3*5^3), w[2] = w1/(5*5^5), ...
# v[0] = 4/239, v[1] = v0/(3*239^3), v[2] = v1/(5*239^5), ...
# m[n] = ± (w[n-1]/(2n-1)(5^2) - v[n-1]/(2n-1)(239^2))
#!/usr/bin/python
# -*- coding: utf-8 -*-
u'''
連立方程式の解法
テスト用の式
2*x1 + 3*x2 + x3 = 4
4*x1 + x2 - 3*x3 = -2
-x1 + 2*x2 + 2*x3 = 2
'''
@poochin
poochin / nsinf.py
Created November 14, 2011 09:00
名前空間推測
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from inspect import currentframe
import re
class At:
'''Namespace inference class
@poochin
poochin / gist:1423262
Created December 2, 2011 13:35
sl コマンドに京急AAを追加するパッチです
diff -c sl/sl.c sl_kq/sl.c
*** sl/sl.c 1998-07-22 23:01:01.000000000 +0900
--- sl_kq/sl.c 2011-12-02 21:34:09.540165908 +0900
***************
*** 33,73 ****
#include "sl.h"
int ACCIDENT = 0;
int LOGO = 0;
int FLY = 0;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# threading base code
# http://techno-st.net/2010/02/06/python-3.html
'''
スタープラチナ Vs. ザ・ワールド
Version 1.0.0
'''
import sys
@poochin
poochin / gist:1619121
Created January 16, 2012 04:49
tumblr life 1.0.0pre8 に標準以外のチャンネルに reblog する機能を追加するパッチ
diff -Naru 1.0_0/script.js 1.0_0p/script.js
--- 1.0_0/script.js 2012-01-16 13:42:39.771423716 +0900
+++ 1.0_0p/script.js 2012-01-16 13:47:48.915422946 +0900
@@ -12,6 +12,14 @@
(function(w, content_window, d) { 'use strict';
+var channels = (function(objs) {
+ var names = [];
+ for (var i = 1; i < objs.length; ++i) {
@poochin
poochin / tumblrd2pub.py
Created January 26, 2012 15:30
tumblelogのdraftをpublishします。 -r(--reverse) オプションで古い順に published 出来るようにしました。
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
name: tumbled2pub
desc: Tumblelog の Drafts を公開するスクリプト
license: MIT
version: ('x')?
'''
~/ $ no-command
command not found: no-command
~/ $ echo $?
127
~/ $ ls --no-option
ls: オプション '--no-option' を認識できません
詳しくは `ls --help' を実行して下さい。
~/ $ echo $?
2
~/ $