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.
@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 / generate-random-rle.rb
Last active April 8, 2019 15:04
generate all golly non-totalistic rules
random = `ruby non-totalistic-rules-random-picker.rb`
puts <<EOS
#CXRLE Pos=0,0
x = 328, y = 264, rule = #{random}
b4ob2ob2obo3bobobob5obobobo3bo2b3o2bo2bo3b2obo2b4ob2o4bob2ob4ob3o4b3o
2b3o6bo3b2o2bo3b2o3bo6b2obob3o2bo2bobobo7bob4o3bo7b2o5bob4o2bob2o3bob
2o4b2o2b2o3bobo4b2o3bobo3bob4o2bobobob4ob6ob2o2b3obo8bo4b2o2bob5ob3o3b
o3b2o2b3o3b2obo3bo3bo4b4ob2o2bo$2o3bobo2b5obob2obobobo2b2o2b2o3bo4b2o
2bo2bob2o4b2ob3o2b3o3b2o3b4ob4o3bob2ob3obob4o2bo3b2obobo2b2ob3obob2obo
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