Skip to content

Instantly share code, notes, and snippets.

View TakashiNakagawa's full-sized avatar

TakashiNakagawa TakashiNakagawa

View GitHub Profile
;1.11
;n < 3 f(n) = n, n >= 3 f(n) = f(n - 1) + 2f(n - 2) + 3f(n-3)
(define (func n)
(cond ((< n 3) n)
(else (+ (func (- n 1)) (* 2 (func (- n 2))) (* 3 (func (- n 3)))))))
(print (func 10))
(define (func n)
(func-iter 2 1 0 n))
;1.12 pascal's triangle
(define (func n m)
(cond ((= n 1) 1)
((= m 1) (func (- n 1) m))
((= m n) (func (- n 1) (- m 1)))
(else (+ (func (- n 1) (- m 1) ) (func (- n 1) m)))))
(print (func 5 3))
;1.12 pascal's triangle
(define (func n m)
(cond ((= n 1) 1)
((= m 1) (func (- n 1) m))
((= m n) (func (- n 1) (- m 1)))
(else (+ (func (- n 1) (- m 1) ) (func (- n 1) m)))))
(print (func 5 3))
# coding: utf-8
require "fileutils"
require 'find'
count = 0
Find.find('./check_xml'){|f|
if File.basename(f) == ".DS_Store"
next
end
@TakashiNakagawa
TakashiNakagawa / gist:4700560
Last active August 1, 2017 02:29
alfredからevernoteへポストする ノートブックはIdeas ノート名は日付 同一日付なら追記される
-- ノートブックの指定
property nb : "Ideas"
property _newNote : missing value
on alfred_script(q)
set _inputText to q
set AppleScript's text item delimiters to "-open"
set _text to text items of _inputText
#import "MyWebViewController.h"
#import "AFNetworking.h"
#if false // facebook
#define LOGIN_URL @"http://sample/login.php?command=facebook&app=true"
#define REDIRECT_URL @"command=facebook_cb"
#else
@TakashiNakagawa
TakashiNakagawa / gist:5062668
Created March 1, 2013 05:36
http://d.hatena.ne.jp/tanakahisateru/20111003/1317623104 $ git diff --name-status HEAD~1 M foo/bar.html A foo/baz.html ... というふうに変更がどうだったかを確認できたら、そのままコマンドラインのヒストリを戻ってちょっと書き足します。 $ git diff --name-status HEAD~1 | export-diff.py ../last-update
#!/usr/bin/env python
#!coding: utf-8
import sys, os, re, shutil
from optparse import OptionParser
parser = OptionParser(usage=
'''%prog [options] <target-dir>
Example:
@TakashiNakagawa
TakashiNakagawa / copy.rb
Last active December 23, 2015 05:59
opencvのincludeファイルコピー
require "find"
require "fileutils"
def copy(source_path, target_path)
Find.find(source_path) do |source|
next if File.directory? source
#パスにopencv2が含まれていなければ除外
next unless File.dirname(source).include?("opencv2")
(define (sum term a next b)
(if (> a b)
0
(+ (term a)
(sum term (next a) next b))))
; (define (pi-sum a b)
; (define (pi-term x)
; (/ 1.0 (* x (+ x 2))))
; (define (pi-next x)
; (+ x 4))
@TakashiNakagawa
TakashiNakagawa / camera.py
Created May 6, 2014 02:10
computer vision5章
#!/usr/bin/python
# -*- coding: utf-8 -*-
from numpy import *
from scipy import linalg
class Camera(object):
""" ピンホールカメラを表すクラス """
def __init__(self,P):