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
template< typename F >
void tenTimes(F f)
{
for (auto i = 0; i < 10; ++i) {
f();
}
}
int main()
{
@kinoshita-lab
kinoshita-lab / chapter4-repl.scm
Created January 21, 2016 05:39
SICP chapter4 basic implementation
;; eval
;; http://www.serendip.ws/archives/1817
;; ↑eval の定義を apply の定義よりも先に行っていたために、eval の定義の中で使っていた apply 手続きが Gauche のシステムの apply 手続きを利用していたために動作しなかったらしい。
;; apply の定義を eval の定義よりも先に行うようにしたところ、正常に動作するようになった。
;; 基盤の apply への参照を apply-in-underlying-scheme へ退避させる(こうすることで、基盤の apply に apply-in-underlying-scheme という名前でアクセスできる)。
(define apply-in-underlying-scheme apply)
;; apply
(define (apply procedure arguments)
@kinoshita-lab
kinoshita-lab / keymap.cson
Created January 26, 2016 00:22
emacs-like key bindings for atom
# Your keymap
#
# Atom keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
# Here's an example taken from Atom's built-in keymap:
@kinoshita-lab
kinoshita-lab / zc.scm
Created April 10, 2016 04:22
Z combinator
;; http://daretoku-unix.blogspot.jp/2015/01/y.html
(define fact
((lambda (h) ;; Yc
((lambda (f) ;; |
(h (lambda (x) ;; |
((f f) x)))) ;; |
(lambda (f) ;; |
(h (lambda (x) ;; |
((f f) x)))))) ;; -
(lambda (f) ;; fact%
int currentStep = 0;
constexpr int NUM_STEP = 16;
// d3 d4 d5 = 74hc138 in a b c
const uint8_t LED_BIT_TABLE[NUM_STEP][3] = {
{0, 0, 0},
{1, 0, 0},
{0, 1, 0},
{1, 1, 0},
@kinoshita-lab
kinoshita-lab / shiromono-chan.ino
Last active September 7, 2016 12:28
Shiromono-chan a sync utility for trakor and hardware
/*
* shiromono-chan.ino
* Small syncing utility for traktor->hardware
*
* Instructions
* 1. Write this program to Arduino Uno
* 2. Burn "Midi Firmware for Arduino Uno (Moco)" to Arduino Uno's USB chip http://morecatlab.akiba.coocan.jp/lab/index.php/aruino/midi-firmware-for-arduino-uno-moco/?lang=en
* 3. Connect to your Computer
* 4. Start Traktor
* 5. Go to Preferences->"MIDI Clock" and enable clocking
@kinoshita-lab
kinoshita-lab / hoge.scm
Created October 26, 2016 03:39
currying w/ closure
(define example-list '(0 1 2 3 4 5))
example-list
; gosh> (1 2 3 4 5)
;; 最初からある関数を呼ぶ
(filter zero? example-list)
; gosh> (0)
;; 関数をdefineするとこんなかんじ
(define (largerThan2 x)
@kinoshita-lab
kinoshita-lab / hilightItalic.js
Created December 31, 2016 00:16
highlight italic on google document
function hilightItalic() {
var body = DocumentApp.getActiveDocument().getBody();
var editText = body.editAsText();
var text = editText.getText();
for (var i = 0; i < text.length; ++i) {
if (editText.isItalic(i)) {
editText.setForegroundColor(i, i, '#ff0000');
}
}
@kinoshita-lab
kinoshita-lab / runrepl.c
Created March 15, 2017 03:29
simplest embedding guile shell example
// gcc hoge.cpp `guile-config link` -o runrepl
#include <libguile.h>
static void inner_main(void *closure, int argc, char **argv)
{
scm_shell(argc, argv);
}
int main(int argc, char **argv)
{
@kinoshita-lab
kinoshita-lab / gist:f5b72641fcea74e5173c262d067a17a4
Created January 6, 2018 11:38
emacs settings for simple C++ editing
(require 'irony)
(require 'company-irony-c-headers)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
(defun c-mode-company-conf ()
(set (make-local-variable 'company-backends)
'((company-irony