Skip to content

Instantly share code, notes, and snippets.

View tosik's full-sized avatar
🏠
Working from home

Toshiyuki Hirooka tosik

🏠
Working from home
  • Tokyo, Japan
View GitHub Profile
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const tileSize = 10;
const numRows = canvas.height / tileSize;
const numCols = canvas.width / tileSize;
const numEnemies = 5; // お好みの敵の数に設定
const rows = 10;
const cols = 10;
const cellSize = 32;
@tosik
tosik / a.vim
Created June 19, 2020 06:49
fillstruct
" Returns the byte offset for the cursor
function! OffsetCursor() abort
let line = line('.')
let col = col('.')
if &encoding != 'utf-8'
let sep = "\r"
let buf = l:line == 1 ? '' : (join(getline(1, l:line-1), sep) . sep)
let buf .= l:col == 1 ? '' : getline('.')[:l:col-2]
return len(iconv(buf, &encoding, 'utf-8'))
endif
drop table datasets;
create table datasets ( uuid varchar(40), name varchar(100), data jsonb );
INSERT INTO datasets ( uuid, name, data ) VALUES ( '212ea202-36d9-4f7b-b2ff-58a702e7fa5e', 'books',
json_build_object(
'id_integer', 2602, 'id_string', '2602', 'id_float', 2602.0,
'title_integer', 0, 'title_string', 'ぅえりはわへうせぴぽしぷ', 'title_float', 0.0,
'price_integer', 660, 'price_string', '660', 'price_float', 660.0
)
);
INSERT INTO datasets ( uuid, name, data ) VALUES ( 'd18fc8a7-cef1-4dc9-b64d-04fa23c2d516', 'books',

Firestore

GCP_PROJECT_ID の部分を GCP のプロジェクトIDにすると動く go-cloud-workspace はコレクション名

MongoDB

DB_NAME の部分を MongoDB の DB 名にする foo はコレクション名 接続設定は環境変数 MONGO_SERVER_URL にセットする

main.cpp:6:10: error: no viable conversion from 'A<Bar>' to 'A<Foo>'
A<Foo> a = A<Bar>();
^ ~~~~~~~~
main.cpp:3:29: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'A<Bar>' to 'const A<Foo> &' for 1st argument
template <typename T> class A {};
^
main.cpp:3:29: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'A<Bar>' to 'A<Foo> &&' for 1st argument
template <typename T> class A {};
^
1 error generated.
remote/host: python3 host registered plugins []
function remote#host#UpdateRemotePlugins[6]..<SNR>39_RegistrationCommands[15]..remote#host#Require[10]..provider#pythonx#Require[13]..provider#Poll, line 4
Vim(if):ch 15 was closed by the client
Fatal Python error: PyThreadState_Get: no current thread
function remote#host#UpdateRemotePlugins[6]..<SNR>39_RegistrationCommands[15]..remote#host#Require[10]..provider#pythonx#Require[13]..provider#Poll, line 14
Failed to load python host. You can try to see what happened by starting nvim with $NVIM_PYTHON_LOG_FILE set and opening the generated log file. Also, the host stderr is available in messages.
remote/host: generated rplugin manifest: /Users/ocha/.local/share/nvim/rplugin.vim
@tosik
tosik / text.md
Created October 27, 2018 08:28
setup neovim

Setup Neovim

brew install neovim
brew install pyenv
pyenv install 3.7.1
pyenv install 2.7.15
pyenv global 3.7.1 2.7.15
@tosik
tosik / text.md
Created October 27, 2018 07:51
pyenv install cannot work

problems

pyenv install 3.7.1
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.1.tar.xz...
-> https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
Installing Python-3.7.1...
python-build: use readline from homebrew
@tosik
tosik / run_test.vim
Last active October 1, 2018 12:39
run googletest filtered by current file name
function! RunTest()
let filter = substitute(expand('%:t'), "_test.cpp", "", "g")
let filter = substitute(l:filter, ".cpp", "", "g")
let filter = system("ruby -e \"print '" . l:filter . "'.split('_').collect(&:capitalize).join\"")
let lower_filter = tolower(l:filter[0]) . l:filter[1 : -1]
let output = system("make build-test && GTEST_FILTER=*" . l:filter . "*:*" . l:lower_filter . "* build/test")
echo "test finished"
cexpr l:output
endfunction