Skip to content

Instantly share code, notes, and snippets.

View kinoshita-lab's full-sized avatar
🌐
middle of nowhere

kaz saita kinoshita-lab

🌐
middle of nowhere
View GitHub Profile
@kinoshita-lab
kinoshita-lab / gist:6026362
Created July 18, 2013 02:55
ternary conditional expression as an argument
#include <cstdlib>
#include <cstdio>
#include <stdint.h>
void func(bool a)
{
if (a) {
puts("true");
} else {
puts("false");
@kinoshita-lab
kinoshita-lab / gist:7904864
Created December 11, 2013 03:55
learn list comprehension in coffeescript
array = [1...10]
result = ( (item + 1) for item in (item for item in array when item % 2 is 0) when item < 10)
@kinoshita-lab
kinoshita-lab / gist:8091541
Created December 23, 2013 04:14
a css for avoid annoying "selected" status, happened when u double-click on a browser screen
* {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
}
@kinoshita-lab
kinoshita-lab / gist:0f48b55b729806ca2c87
Created May 17, 2014 03:45
remove file extension from a filename
std::string removeExtension(const std::string& fileName)
{
std::string r = fileName;
const size_t dotIndex = r.rfind(".");
if (dotIndex == std::string::npos) {
return fileName;
}
std::string::const_iterator it = r.begin() + dotIndex;
@kinoshita-lab
kinoshita-lab / gist:81e5016b1b14b34dd490
Created September 11, 2014 02:31
ruby variable scope
value = 1
def function
p value
end
function
;d. waveペインタ
(define (wave-painter frame)
(define vect1 (edge1 frame))
(define vect2 (edge2 frame))
(define z (make-vect 0 0))
(define (make-draw-point-vector vect1 vect2 magnitude-vect1 magnitude-vect2)
(add-vect (scale-vect vect1 magnitude-vect1)
(scale-vect vect2 magnitude-vect2)))
(let ((p1 (make-draw-point-vector z vect2 0 0.33)) ; 右足の先
(p2 (make-draw-point-vector vect1 vect2 0.5 0.35)) ; 右足の付け根
@kinoshita-lab
kinoshita-lab / gist:071f76b5db20f6cdb6ec
Last active August 29, 2015 14:15
put & get for 2.4.3
(define put-lists '())
(define (clear-putlist)
(set! put-lists '()))
(define (put op type item)
(if (get op type) put-lists
(set! put-lists (cons (list op type item) put-lists)))) ; setっての使えばやりたいことできそう
(define (get op type)
@kinoshita-lab
kinoshita-lab / gist:b76a55759a0d0968cd97
Last active May 21, 2021 03:57
put-coercion,get-coercion for SICP 2.5.2
(define coercion-list '())
(define (clear-coercion-list)
(set! coercion-list '()))
(define (put-coercion type1 type2 item)
(if (get-coercion type1 type2) coercion-list
(set! coercion-list
(cons (list type1 type2 item)
coercion-list))))

#3.2 評価の環境モデル

第1章で合成手続きを導入した時は、引数に手続きを適用するとはどういうことなのか定義するために、 置き換えモデルを使った(1.1.5)。 つまり、

  • 合成手続きに引数を適用するとは、「仮パラメータをそれぞれ対応した引数に置き換えた上で、 手続きの本体を評価する」

ということである。

@kinoshita-lab
kinoshita-lab / convert.sh
Created November 7, 2015 01:26
convert wav file to mozzi signed 8 bit
#!/usr/bin/env sh
#
# you need sox http://sox.sourceforge.net/
# and copy char2mozzi.py
wavfiles="*.wav"
for wavfile in ${wavfiles}
do
sox ${wavfile} -r 16384 -b 8 -e signed-integer ${wavfile%.wav}.raw
done