Skip to content

Instantly share code, notes, and snippets.

View serihiro's full-sized avatar

Kazuhiro Serizawa serihiro

View GitHub Profile
@serihiro
serihiro / main.java
Last active January 21, 2024 07:12
Lucene in 5 minutes (https://lucenetutorial.com/lucene-in-5-minutes.html) with lucene 9.9.1
package org.example;
import java.io.IOException;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
@serihiro
serihiro / app.py
Last active October 11, 2023 14:33
Elasticsearch search viewer with Streamlit example
import streamlit as st
from elasticsearch import Elasticsearch
def main():
st.title("Streamlit ES Viewer")
with st.form("my_form", clear_on_submit=False):
keyword = st.text_input("keyword", "Python")
title_weight = st.number_input(
label="title weight", value=1.0, min_value=0.0, max_value=5.0, step=0.1
@serihiro
serihiro / examine_imagenet_data_size_and_count.sh
Last active September 9, 2023 06:06
A shell script to count the total size and counts of ImageNet training dataset. For busy people; 1,281,167 images / 146,999,143,316 Byte
#!/bin/bash
BASE_DIR="/path/to/imagenet/train"
ALL_DIRS=`ls $BASE_DIR | grep -v .tar | grep -v .sh`
total_size=0
total_count=0
for dir in $ALL_DIRS
do
target_dir="${BASE_DIR}/${dir}"
@serihiro
serihiro / steps_to_use_autoformat_tex_file.md
Created April 29, 2018 01:54
latexでautoformatを使えるようにするためにやった作業メモ

tlmgrで latexindent をinstall

sudo tlmgr option repository ctan
sudo tlmgr update --self
sudo tlmgr install latexindent

latexindentを実行しようとしたらperlの依存ライブラリが足りてないためにエラーになるのでcpanで色々いれる

@serihiro
serihiro / reading_record_not_unique.md
Last active June 25, 2022 16:06
RecordNotUniqueからカラム情報とか取れないか知りたかったのでrailsのソースを雑に追ってみた

結論

  • SQLiteとMySQLは文字列のエラーメッセージしか持ってないので無理そう
  • PostgreSQLはいけるかもしれないが未確認

ソースリーディング対象branch

  • rails4.2-stable

定義箇所

@serihiro
serihiro / executable.sh
Last active June 3, 2022 09:38
Get MPI rank in the executing shell script
#!/bin/bash
rank=`python get_mpi_rank.py`
if [ ${rank} -eq 0 ]; then
echo 'I am rank 0'
elif [ ${rank} -eq 1 ]; then
echo 'I am rank 1'
elif [ ${rank} -eq 2 ]; then
echo 'I am rank 2'
elif [ ${rank} -eq 3 ]; then
@serihiro
serihiro / settings.json
Last active January 13, 2022 05:59
情報処理学会用latex設定 for latex-workshop
{
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-e",
"$latex=q/platex %O -synctex=1 -interaction=nonstopmode -file-line-error %S/",
"-e",
@serihiro
serihiro / Emoloyee.java
Last active January 1, 2022 12:48
Hot to smart-cast a Java class variable in Kotlin
import javax.annotation.Nullable;
public class Employee {
private String firstName;
private String lastName;
private Integer age;
public Employee(String firstName, String lastName, Integer age){
this.firstName = firstName;
this.lastName = lastName;
@serihiro
serihiro / note.md
Last active December 23, 2021 00:53
パタヘネ 2.10 32ビットの即値およびアドレスに対するMIPSのアドレシング方式
  • MIPSの命令は32ビット固定であるがゆえに32ビットの定数やアドレスを格納することはできない
  • しかし扱えた方が便利な場合がある。そのMIPSにおける解決策を示す

32ビットの即値オペランド

  • 定数は大体が16ビットに収まる(表現できる)が、超えることもある
  • MIPSには16ビットを超える定数の上位16ビットを指定したレジスタの上位16bitに格納するための命令 lui がある
  • 命令フォーマットは Iフィールド で OP(6) + rs(5) + rt(5) + 即値16ビット

例題

@serihiro
serihiro / arm_compute_library_tutorial_note.md
Last active May 21, 2021 18:54
A note about "Running AlexNet on Raspberry Pi with Arm Compute Library" at arm Developer