ビットの海

ゆるふわソフトウェアエンジニアしゃぜのブログ

GCSバケットを空っぽにしてから消す

GCSのbucketを削除したい場合、中身を空っぽにする必要があります。

Webのコンソール画面からやってると相当だるい(ファイルが多いとtimeoutする)ので、gsutilコマンドをおすすめします。

# rmでオブジェクトを消す。-mオプションでマルチスレッド実行、-rオプションで再帰的に全部消す
# このコマンドは中身を全部消すと、最後にバケット自体も消します。
gsutil -m rm -r gs://foo-bucket

isortで特定のimportを必ずtopに持ってきたい

やんごとなき事情により、そういうことをしたい時がある。

元のサンプル(foo.py)

import os
import math


class Foo:
    def foobar():
        print(os.getpid())
        print(math.pi)


if __name__ == "__main__":
    Foo.foobar()

checkするとimport順序で怒られる(アルファベット順でosよりmathが先じゃろって)

isort --check-only foo.py
ERROR: /Users/foobaruser/python-test1/foo.py Imports are incorrectly sorted.

.isort.cfg に force_to_topしてみる

[settings]
force_to_top=os

エラーにならない

isort --check-only foo.py

pythonコーディング用にneovimを最低限整える(2019年春)

もうこの構成では使っていません shase428.hatenablog.jp

こちらを参照してください。

前提

  • neovim用のvenvと、各種プロジェクトのvenv(ないしそれに類するもの)の2つの概念がある。
  • pyenvでもなんでもいいのでpython3がちゃんと動く状態にある。
  • pluginマネージャとして、deinをつかっている(tomlで)。
  • ALEはまだ悩み中。
  • 一旦最低限ですわ。

イメージ

f:id:shase428:20190510203804p:plain

流れ

  1. neovim用のvenv環境用意する
  2. vim pluginの導入と設定

1. neovim用のvenv環境用意する

mkdir ~/neovim-python3
cd neovim-python3/
python3 -m venv neovim
source neovim/bin/activate
pip3 install pynvim flake8 isort

2. vim pluginの導入と設定

今回導入するもの(python向け)

  • 各種補完
    • prabirshrestha/vim-lsp
  • importのソート(isort)
    • fisadev/vim-isort
  • formatter(black)
  • linter
    • nvie/vim-flake8

prabirshrestha/vim-lsp

plugin設定まだいろいろ悩み中。 この辺を参考にさせていただきました。m ( _ _ ) m

python-language-server をneovim側のvenvじゃなくて、プロジェクト側にpip installしないといけないのが気になっている。 いい方法ないかな。

[[plugins]]
repo = 'prabirshrestha/asyncomplete.vim'

[[plugins]]
repo = 'prabirshrestha/asyncomplete-lsp.vim'

[[plugins]]
repo = 'prabirshrestha/async.vim'

[[plugins]]
repo = 'prabirshrestha/vim-lsp'
depends = 'async.vim'
hook_add = '''
augroup ProjectLSP
  autocmd!
  let s:pyls_path = fnamemodify(g:project_python_path, ':h') . '/'. 'pyls'
  if executable('pyls')
    autocmd User lsp_setup call lsp#register_server({
        \ 'name': 'pyls',
        \ 'cmd': { server_info -> [expand(s:pyls_path)] },
        \ 'whitelist': ['python']
        \})
  endif
augroup END

function! s:configure_lsp() abort
  setlocal omnifunc=lsp#complete
  nnoremap <buffer> <C-]> :<C-u>LspDefinition<CR>
  nnoremap <buffer> gd :<C-u>LspDefinition<CR>
  nnoremap <buffer> gD :<C-u>LspReferences<CR>
  nnoremap <buffer> gs :<C-u>LspDocumentSymbol<CR>
  nnoremap <buffer> gS :<C-u>LspWorkspaceSymbol<CR>
  nnoremap <buffer> gQ :<C-u>LspDocumentFormat<CR>
  vnoremap <buffer> gQ :LspDocumentRangeFormat<CR>
  nnoremap <buffer> K :<C-u>LspHover<CR>
  nnoremap <buffer> <F1> :<C-u>LspImplementation<CR>
  nnoremap <buffer> <F2> :<C-u>LspRename<CR>
endfunction

augroup LaunchPyls
    autocmd!
    autocmd BufWinEnter *.py :call lsp#enable()
augroup END

augroup PylsCommands
    autocmd!
    autocmd BufWinEnter *.py :call lsp#enable()
    " local key mapping
    autocmd FileType python nnoremap <C-]> :<C-u>LspDefinition<CR>
    autocmd FileType python nnoremap K :<C-u>LspHover<CR>
    autocmd FileType python nnoremap <LocalLeader>R :<C-u>LspRename<CR>
    autocmd FileType python nnoremap <LocalLeader>n :<C-u>LspReferences<CR>
augroup END

let g:lsp_diagnostics_enabled = 0
'''

例によって、 g:project_python_path を渡しています。

fisadev/vim-isort

plugin設定

[[plugins]]
repo = 'fisadev/vim-isort'
on_ft = ['python']

python/black

plugin設定

[[plugins]]
repo = 'python/black'
on_ft = ['python']

nvie/vim-flake8

plugin設定

[[plugins]]
repo = 'nvie/vim-flake8'
on_ft = ['python']
hook_source = '''
    let g:flake8_show_in_gutter=1
    let g:flake8_show_in_file=1
    let s:flake8_path = fnamemodify(g:project_python_path, ':h') . '/'. 'flake8'
    let g:flake8_cmd = expand(s:flake8_path) . " --config " . expand(g:project_flake8_config)
'''

g:project_python_path で、プロジェクトごとの setup.cfg を参照するようにしている。

NHK総合だけが映らないので切り分けした話

子どもが生まれてからというもの、NHK(教育)に頼り切り。

そんな中、NHK(総合)が映らないときがあると言われて、実際に受信レベルを見てみると...。

f:id:shase428:20190310180729j:plain

おおーこれはひどい。時間帯にもよるが、受信レベルが低いようだ。 アンテナ周りをまず疑うが、他のチャンネルは写っているのと、そもそもマンション単位でJ-COMなので、その可能性は低いと判断。

となると、(ネットで調べたぐらいだと)家庭内でのアンテナ線がノイズを拾ってしまっているのかな?と推測。 見たところ、アンテナ線はテレビ(かレコーダー)付属のノンシールドそうなものである。

というわけで、金メッキのシールド線を電気屋で購入

取り付けしてみると...

f:id:shase428:20190310181153j:plain

劇的な受信レベルの改善。だめだったらブースター買わないとかな〜とも思っていたので安上がりで済んでよかった。

物理層って大事だな〜

SIMフリーのiPhone 8買いました

f:id:shase428:20180804232849j:image

SIMフリーiPhone 8 256GBモデルとみおぽんにしました。iPhone 6sをMNOで使っていましたがいろいろ限界感じてしまって。。。

今のところ不便な点は無いですね。

しかし、携帯ごときに10万超える時代ってすごいよね(╹◡╹)

 

ふわっとOpenResty

前提

  • brewがつかえる環境

導入

$ brew install openresty/brew/openresty

設定

$ cd /usr/local/opt/openresty
$ mkdir conf
$ mkdir lua

サンプル配置

/usr/local/opt/openresty/conf/nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    charset UTF-8;
    server {
        listen       80;
        server_name  localhost;

        location / {
                default_type 'text/html';
                content_by_lua_file /usr/local/opt/openresty/lua/hello.lua;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

}

/usr/local/opt/openresty/lua/hello.lua

ngx.say("こんにちは世界")

起動と停止

# 起動
sudo /usr/local/opt/openresty/bin/openresty -c /usr/local/opt/openresty/conf/nginx.conf

# 停止
sudo /usr/local/opt/openresty/bin/openresty -s stop

起動してhttp://localhostにアクセスしてみよう!

Oracle JDBC Driverについて淡々とまとめる(2019年6月追記)

2024.01.24 追記

まだアクセスあるけど、今は公式サイトがわかりやすいからそこを見れば良いと思います。

この記事は公式サイトがめっちゃわかりにくかった時代に作ったものです。

JDBC and UCP Downloads page

おことわり

  • 2018年7月現在の情報に、2019年6月追記
  • 11gR2以降

まとめ

oracle version jar file JDK Certified download link
11g R2 (11.2.0.4), (11.2.0.3), (11.2.0.2.0), (11.2.0.1.0) drivers ojdbc5.jar For use with JDK1.5 link
11g R2 (11.2.0.4), (11.2.0.3), (11.2.0.2.0), (11.2.0.1.0) drivers ojdbc6.jar Certified with JDK8, JDK7, and JDK6 link
12c R1(12.1.0.1) drivers ojdbc6.jar For use with JDK6 link
12c R1(12.1.0.1) drivers ojdbc7.jar Certified with JDK7 and JDK8 link
12c R1(12.1.0.2) drivers ojdbc6.jar For use with JDK6 link
12c R1(12.1.0.2) drivers ojdbc7.jar Certified with JDK7 and JDK8 link
12c R2(12.2.0.1) drivers ojdbc8.jar Certified with JDK 8 link
18c (18.3) drivers ojdbc8.jar JDK Certified 表記なし link
19c (19.3) drivers ojdbc8.jar Certified with JDK8 link
19c (19.3) drivers ojdbc10.jar Certified with JDK10 link

メモ

  • ojdbc6.jarという同じ名前でも中身が異なる(ややこしい)

関連