cのソースをビルド&runする fish shell のコマンド
function gcc_build -d "cのソースをビルド&runする" set c_file $argv set o_file (string replace ".c" ".o" $c_file) gcc $c_file -o $o_file eval ./$o_file end
so that 構文の4種類の用法
当時、筆者が中学で習った so that 構文は「とても~なので…です」 と1種類だけなので容易に覚えることができました。 しかしながら、仕事で英語に触れる機会が増えてくると、上と似たような so that が出てくる文章ではあるけれども、上の意味で訳すとどうも意味が通らないケースが多いのです。 そこでよくよく調べてみますと、 so that 構文には4種類の用法がありました。
1. 程度・結果(~するほど...だ、とても...なので~だ)
so の後に 形容詞か副詞
がきます。
まずは中学英語で習った so that 構文ですね。
He is so hungry, that he can eat anything. (彼はなんでも食べられる程空腹だ。)
too~ to... (あまりに~すぎて、... できない) と書き換えさせる問題がよく出題されました。
2. 様態(~するように...)
so の後に 過去分詞
がきます。
This bicycle is so made that it drives speedy. (この自転車は早く走れるように作られている。)
様態とは聞き慣れない言葉ですが、「物事のありかた。様相」という意味です。
3. 目的(~するために...)
so と that がくっついています。
後節が目的を示す節となっています。
I work so that I earn money for tuition of university. (私は大学の学費を稼ぐために働いている。)
The Architecture of Open Source Applications (Volume 2): nginx の 14.4. nginx Internals を読んでいて見つけたので訳してみます。
For a directory it would automatically rewrite the URI so that the trailing slash is always there (and then issue an HTTP redirect). (ディレクトリの場合は、trailing slash を付加するために自動的でURIに変換されます。その後、HTTP リダイレクトが行われます。)
4. 結果(~その結果...)
- のパターンに加えてカンマが先頭につきます。
I study hardly, so that I passed the difficult examination. (ハードに勉強した。その結果、難しい試験をパスした。)
省略について
so that 構文では、口語では that が, 文語では so が省略されることがよくあるようです。
- 口語
I study hardly, so I passed the difficult examination.
- 文語
I study hardly, that I passed the difficult examination.
うーん。口語の方はわかるんですが、文語の方はこの事をわかってないと、なかなか意味を取るのは難しそうですね。 初期に習う単語ほど、色々な語法が多くて混乱の要因になることが多い気がします。
参考にした記事
こちらの記事を参考にさせていただきました。ありがとうございます!
Rubyでグラフを表現してみる
class Vertex attr_accessor :id, :edges def initialize(id, edges=[]) @id = id @edges = edges end def print puts "#{ @id }" @edges.each do |edge| puts edge end end end class Edge attr_accessor :id, :from, :to, :length def initialize(id, from, to, length) @id = id @from = from @to = to @length = length end def to_s "#{ from } => #{ to } #{ length }" end end class Graph attr_accessor :vertexes, :edges def initialize(data) @vertexes = [] data.each do |k, v| edges = [] v.each do |k2, v2| edges << Edge.new( 0, k ,k2, v2 ) end @vertexes << Vertex.new( k, edges ) end end def print_graph @vertexes.each do |v| v.print end end end data = { a: {b: 1, c: 3, d: 4}, b: {b: 3, d: 11}, c: {a: 1}, d: {e: 11}, e: {a: 1}, } g = Graph.new( data ) g.print_graph
実行結果
a a => b 1 a => c 3 a => d 4 b b => b 3 b => d 11 c c => a 1 d d => e 11 e e => a 1
Kernel#systemと`` の挙動の違い
戻り値
p system "ls" # => true p `ls` # => "Capfile\nGemfile\nGemfile.lock\n...."
エラー時の挙動
p system "ls2" # => nil p `ls2` # => No such file or directory - ls2 (Errno::ENOENT) の例外が発生し、 空文字列がかえる
p ls2
の例については begin, rescue で囲って動作確認した。
RubyMineでファイルのシンタックスハイライトが効かないときの対応方法
bash
のコードは拡張子がなくてRubyMine側がファイルの種類を判断できなかったりするので、自分で指定する必要がある。
Help > Find Action... > Action > Associate with File Type...
で指定できる。
Find Action
は shift 2回でも起動できる。
ローカルにある不要になった remote-tracking branch を削除する
remote-tracking branch を削除する方法
remote-tracking branch とはローカルにあるリモートレポジトリの追跡ブランチのことです。
私たちが手元で使うローカルブランチは、 git fetch して、このremote-tracking branch をローカルに作成した後に、
ここからさらに git checkout -b して生成されます。
開発が終わり、無事マージした後にこの remote-tracking branch は不要になります。
remote (ex. GitHub上) で削除済みのブランチであれば git remote prune origin
で消せるのですが、
そうでないブランチは消せません。しかし、以下の方法で消すことができます。
%w( origin/test origin/fix origin/fix_typo ).each do |bra| system("git branch -d -r #{ bra }") end
削除前は、 git status, git diff などのコマンドが重かったのですが、実行後は幾分か軽くなりました。
参考にさせていただきました
追記
`git branch --all`.split("\n").map(&:strip).select{|s| s.match(/^remotes\//)}.each do |bra| system("git branch -d -r #{ bra.gsub(/^remotes\//, "") }") end