<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>akeboshi blog</title>
    <link>https://blog.akeboshi.dev/</link>
    <description>Recent content on akeboshi blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>ja-jp</language>
    <lastBuildDate>Sat, 06 Mar 2021 12:29:18 +0000</lastBuildDate>
    
	<atom:link href="https://blog.akeboshi.dev/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>JavaのArrayListの配列の大きさについて</title>
      <link>https://blog.akeboshi.dev/post/java%E3%81%AEarraylist%E3%81%AE%E9%85%8D%E5%88%97%E3%81%AE%E5%A4%A7%E3%81%8D%E3%81%95%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6/</link>
      <pubDate>Sat, 06 Mar 2021 12:29:18 +0000</pubDate>
      
      <guid>https://blog.akeboshi.dev/post/java%E3%81%AEarraylist%E3%81%AE%E9%85%8D%E5%88%97%E3%81%AE%E5%A4%A7%E3%81%8D%E3%81%95%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6/</guid>
      <description>Java のArrayListはListの実装でみなさんよく使ってると思います。
配列を使ってListを実装しているが、どうやって配列の大きさを決めて配列を作っているかを見ていく
 ref:  ArrayList: https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/ArrayList.java ArraysSupport: https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java   結論  new するときは想像の通りで、何も指定されなければ空、指定されればそのサイズの配列が内部で作られる。 add するときは、(addされる前の配列の大きさ &amp;gt;&amp;gt; 1) 分増えるので、addされる前の大きさの 1&amp;frasl;2 倍分増える addAll するときは、addするときと同じでサイズで配列のサイズが足りれば、addするときと同じ。足りなければ、必要な分丁度の配列が作られる。 要素を消しても初期サイズに戻ったりはしない  実装を読む new new ArrayList() しただけだと、空の配列が作られる
public ArrayList() { this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA; // 空の配列 }  new ArrayList(initialCapacity) すると、指定したサイズの大きさの配列が作られる。
public ArrayList(int initialCapacity) { if (initialCapacity &amp;gt; 0) { this.elementData = new Object[initialCapacity]; } else if (initialCapacity == 0) { this.elementData = EMPTY_ELEMENTDATA; } else { throw new IllegalArgumentException(&amp;quot;Illegal Capacity: &amp;quot;+ initialCapacity); } }  add new ArrayList(5) をして、中身が [1,2,3,4,5] のを例として</description>
    </item>
    
    <item>
      <title>ActionText がどのようにHTMLを保存しているか</title>
      <link>https://blog.akeboshi.dev/post/actiontext-%E3%81%8C%E3%81%A9%E3%81%AE%E3%82%88%E3%81%86%E3%81%ABhtml%E3%82%92%E4%BF%9D%E5%AD%98%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E3%81%8B/</link>
      <pubDate>Fri, 26 Feb 2021 07:12:12 +0000</pubDate>
      
      <guid>https://blog.akeboshi.dev/post/actiontext-%E3%81%8C%E3%81%A9%E3%81%AE%E3%82%88%E3%81%86%E3%81%ABhtml%E3%82%92%E4%BF%9D%E5%AD%98%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E3%81%8B/</guid>
      <description>ActionText の本文は、 action_text_rich_texts.body に保存される。どのように保存されるか見ていく。 active storage を使った画像データとのリンクは個々では触れない
has_rich_text 任意のモデルで、 has_rich_text を定義すると、 ActionText::RichText への has_one が定義される。 これで、任意のモデルから ActionText::RichText モデルへのポリモーフィックな依存が作られる
def has_rich_text(name) class_eval &amp;lt;&amp;lt;-CODE, __FILE__, __LINE__ + 1 def #{name} rich_text_#{name} || build_rich_text_#{name} end def #{name}? rich_text_#{name}.present? end def #{name}=(body) self.#{name}.body = body end CODE has_one :&amp;quot;rich_text_#{name}&amp;quot;, -&amp;gt; { where(name: name) }, class_name: &amp;quot;ActionText::RichText&amp;quot;, as: :record, inverse_of: :record, autosave: true, dependent: :destroy scope :&amp;quot;with_rich_text_#{name}&amp;quot;, -&amp;gt; { includes(&amp;quot;rich_text_#{name}&amp;quot;) } scope :&amp;quot;with_rich_text_#{name}_and_embeds&amp;quot;, -&amp;gt; { includes(&amp;quot;rich_text_#{name}&amp;quot;: { embeds_attachments: :blob }) } end  https://github.</description>
    </item>
    
    <item>
      <title>Git の master/main への直接pushを防ぐ</title>
      <link>https://blog.akeboshi.dev/post/git-%E3%81%AE-master-main-%E3%81%B8%E3%81%AE%E7%9B%B4%E6%8E%A5push%E3%82%92%E9%98%B2%E3%81%90/</link>
      <pubDate>Tue, 23 Feb 2021 05:59:03 +0000</pubDate>
      
      <guid>https://blog.akeboshi.dev/post/git-%E3%81%AE-master-main-%E3%81%B8%E3%81%AE%E7%9B%B4%E6%8E%A5push%E3%82%92%E9%98%B2%E3%81%90/</guid>
      <description>誤って master/main へ直接pushしてしまわないようにクライアント側のhookで、特定のbranch名へのpushを禁止する
ref: https://git-scm.com/docs/githooks
プロジェクトごとの pre-push hook プロジェクトごとの hook path は .git/hooks/ になっているので、ここにファイルを作成する。
#!/bin/bash protected_branches=(&#39;main&#39; &#39;master&#39;) while read local_ref local_sha1 remote_ref remote_sha1 do if [[ &amp;quot;${protected_branches[@]}&amp;quot; =~ &amp;quot;${remote_ref##refs/heads/}&amp;quot; ]]; then echo &amp;quot;Do not push to master branch!!!&amp;quot; exit 1 fi done  (参考) hook の template を作る init する際に、template をもとに、そのプロジェクトにhookが追加される
git config --global init.templatedir &amp;quot;~/.git_template/&amp;quot;  #!/bin/bash protected_branches=(&#39;main&#39; &#39;master&#39;) while read local_ref local_sha1 remote_ref remote_sha1 do if [[ &amp;quot;${protected_branches[@]}&amp;quot; =~ &amp;quot;${remote_ref##refs/heads/}&amp;quot; ]]; then echo &amp;quot;Do not push to master branch!</description>
    </item>
    
    <item>
      <title>GitHub をHTTPSで使う</title>
      <link>https://blog.akeboshi.dev/post/github-%E3%82%92https%E3%81%A7%E4%BD%BF%E3%81%86/</link>
      <pubDate>Tue, 23 Feb 2021 05:41:27 +0000</pubDate>
      
      <guid>https://blog.akeboshi.dev/post/github-%E3%82%92https%E3%81%A7%E4%BD%BF%E3%81%86/</guid>
      <description>GitHubではsshよりhttpsでの通信を推奨している
sshを使ってgitを使ってる人も多いと思うので、httpsを使ってgitを使う方法を書く
linux の cui 環境での想定のため、gnome-keyring などはメインで扱わない
credential helper を設定する helper を設定することで、毎回 account, password を入力する手間を省く
なお、 github で 2FA を利用している場合は、access tokenを発行して password の代わりに入力する必要がある。
ref: https://git-scm.com/book/ja/v2/Git-%E3%81%AE%E3%81%95%E3%81%BE%E3%81%96%E3%81%BE%E3%81%AA%E3%83%84%E3%83%BC%E3%83%AB-%E8%AA%8D%E8%A8%BC%E6%83%85%E5%A0%B1%E3%81%AE%E4%BF%9D%E5%AD%98
cache を使い一定時間記憶させる helper に cache を指定することで一定時間 account, password を記憶させておくことが出来る
--timeout option を利用して、キャッシュさせておく時間を指定出来る (default は 900 秒)
# 1時間 cache させておく git config --global credential.helper &amp;quot;cache --timeout 3600&amp;quot;  # 一回目は username, password を聞かれる % git push -n Username for &#39;https://github.com&#39;: Password for &#39;https://xxx@github.com&#39;: # 二回目は聞かれない % git push -n  store を使いディスクに保存する helper に store を指定することで、 account, password をディスクに保存することが出来る。 これをすることで、 password を変更したり、tokenを無効化するまで account, password の入力をシなくても良くなります。 ただし、 file に password が暗号化されずに保存されているため、リスクがあります。</description>
    </item>
    
    <item>
      <title>AviUtil で GPUを使ったエンコード</title>
      <link>https://blog.akeboshi.dev/post/aviutil-%E3%81%A7-gpu%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%9F%E3%82%A8%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%89/</link>
      <pubDate>Wed, 05 Aug 2020 10:15:49 +0000</pubDate>
      
      <guid>https://blog.akeboshi.dev/post/aviutil-%E3%81%A7-gpu%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%9F%E3%82%A8%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%89/</guid>
      <description>AviUtil で h.264 のエンコードをする
必要なもの  AviUtl 拡張編集Plugin NeroAACCodec L-SMASH L-SMASH Works Geforceの場合 NVEnc Radeonの場合 VCEEnc  各種インストールする AviUtl をインストール これが、動画編集ソフト本体になる
 ダウンロードしたものを解凍するだけ  拡張編集Pluginをインストール aviutl で、複数の動画や音楽ファイルを読み込んだり、文字を挿入したりなどできるようになる。 (エンコードに必須ではない)
 aviutl.exe のあるディレクトリに Plugins ディレクトリを作成する 拡張編集Plugin を解凍した中にある exedit.txt に従って、解凍したファイルすべてを Plugins ディレクトリにコピーする  NeroAACCodec をインストール 音声のエンコードをする。一応これがなくてもできるはずだが、デフォルトがこれ
 aviutl.exe のあるディレクトリに exe_files ディレクトリを作成する NeroAACCodecを解凍し、解凍したディレクトリの中の win ディレクトリの中のファイルをすべて exe_files にコピーする  L-SMASH 音声のエンコードをしたものを動画のエンコードの中にいれるもの (多分)
 解凍したディレクトリの中身をすべて exe_files にコピーする  L-SMASH Works MP4 などの動画を aviutl で読み込めるようにする
 解凍して、 lwcolor.</description>
    </item>
    
  </channel>
</rss>