This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 🐛 fix: | |
| # ✨ feat: | |
| # ♻️ refactor: | |
| # ✅ test: | |
| # 📝 docs: | |
| # 📦 package: | |
| # ⚡️ perf: | |
| # 💚 ci: | |
| # ⚠️ warn: | |
| # 👮 lint: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def merge(left, right) | |
| array = [] | |
| i = 0 | |
| j = 0 | |
| loop do | |
| break if left[i].nil? || right[j].nil? | |
| if left[i] < right[j] | |
| array << left[i] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def bubble_sort(array) | |
| array.size.times do |i| | |
| array.size.times do |j| | |
| if array[i] < array[j] | |
| array[i], array[j] = array[j], array[i] | |
| end | |
| end | |
| end | |
| array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def partition(array, range) | |
| head = range.first | |
| tail = range.last | |
| pivot = array[head] | |
| loop do | |
| # 取替候補を見つける(pivot以上の値を探す) | |
| head += 1 while head <= tail && array[head] < pivot | |
| tail -= 1 while head <= tail && array[tail] >= pivot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 変数の内容を調べるには関数 print で内容を出力する。 | |
| この関数の引数には変数名を与える。 | |
| scratch バッファで下記のプログラムを実行してみよう。 | |
| (defvar my/list '(magit key-chord)) | |
| (print my/list) | |
| リスト (magit key-chord) が出力される。 | |
| M-x で実行するときは describe-variable のほうがよい。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # recursive version | |
| def fib(x) | |
| (x <= 1) ? 1 : fib(x-2) + fib(x-1) | |
| end | |
| # loop version | |
| def fib(x) | |
| fibs = [] | |
| x.times do |i| | |
| fibs[i] = (i <= 1) ? 1 : fibs[i-2] + fibs[i-1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # img , cue があるディレクトリでこのスクリプトを実行すると mp3 で抽出する。 | |
| # 予め bchunk, lame をインストールする必要がある。brew を使うと楽。 | |
| IMG_NAME=(*.img) | |
| CUE_NAME=(*.cue) | |
| BASE_NAME=${IMG_NAME%.*} # cut extension | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 【シェル(端末)の開き方】 | |
| # ランチャーの一番上の「Dashホーム」ってアイコンを押します。アプリケーションを検索する状態になります。 | |
| # term と打ったら「端末」ってアイコンが出るのでそれを押します。 | |
| # パッケージリストを更新した後、今後使うパッケージをまとめてインストールします。 | |
| sudo apt-get update | |
| sudo apt-get install -y git build-essential libssl-dev libsqlite3-dev nodejs | |
| # rbenv をダウンロードします。(ruby のインストーラだと思ってください) | |
| git clone https://github.com/sstephenson/rbenv.git ~/.rbenv |