Skip to content

Instantly share code, notes, and snippets.

View pandanote-info's full-sized avatar

pandanote-info pandanote-info

View GitHub Profile
@pandanote-info
pandanote-info / QuaternionTest.scala
Created July 16, 2018 13:44
Scalaで四元数を扱うためのクラス及びテストのための簡易テスト用のコード。
package info.pandanote.test
import Quaternion._
object QuaternionTest {
def main(args: Array[String]): Unit = {
val a = Quaternion(-2,4,-3,3)
val b = Quaternion(-3,3,5,0)
val c = Quaternion(5,0,9,-4)
@pandanote-info
pandanote-info / txt2exo.py
Last active October 1, 2018 14:24
AviUtl用字幕の量産ツールです。Python3で記述しています。
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# テキストファイルを1行ずつ読み込み、exoフォーマットで記述されたAviUtlの
# 字幕のテンプレートに挿入して、exoフォーマットで標準出力に出力するプログラム。
# Copyright 2017,2018 pandanote.info (https://pandanote.info/)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@pandanote-info
pandanote-info / test_output_utf8.exo
Created July 21, 2018 08:34
AviUtl用字幕の量産ツールtxt2exo.pyによる出力例をUTF-8に変換したファイル。実際に使用する際には文字コードをShift JISに変換すること。
[exedit]
width=1920
height=1200
rate=30
scale=1
length=402
audio_rate=44100
audio_ch=2
[0]
start=1
@pandanote-info
pandanote-info / SevenZFileInputStream.java
Created August 6, 2018 13:42
Apache SolrのDataImportHandlerに7-zipで圧縮されたファイルを読み込ませるために実装したInputStream。
package info.pandanote.szdi;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.compress.archivers.sevenz.SevenZFile;
public class SevenZFileInputStream extends InputStream {
SevenZFile sevenZFile = null;
@pandanote-info
pandanote-info / SevenZFileDataSource.java
Last active August 6, 2018 13:45
Apache SolrのDataImportHandlerで使用するDataSourceで、7-zipで圧縮されたファイルを読み込むことをできるように拡張したもの。
package info.pandanote.szdi;
import static org.apache.solr.handler.dataimport.DataImportHandlerException.SEVERE;
import static org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
@pandanote-info
pandanote-info / dih-config.xml
Created August 7, 2018 11:42
SevenZFileDataSourceクラスを使ってデータをインポートする場合のDataImportHandler用の設定ファイルの設定例。
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource type="info.pandanote.szdi.SevenZFileDataSource" basePath="${solr.install.dir}/../jawiki"
encoding="utf-8"/>
<document>
<entity
name="document"
processor="FileListEntityProcessor"
baseDir="${solr.install.dir}/../jawiki"
fileName=".*-solr\.7z$"
@pandanote-info
pandanote-info / solrconfig-dih.xml
Created August 7, 2018 13:21
SevenZFileDataSourceを使用するためにsolrconfig.xmlに追記した設定例。configタグの内側に記述すること。
<!-- configタグの内側に以下の記述を追加する。 -->
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-extras-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="SevenZDataImporter-\d.*\.jar" />
<requestHandler name="/dataimport" startup="lazy" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">dih-config.xml</str>
</lst>
</requestHandler>
@pandanote-info
pandanote-info / NormDistTest.java
Last active September 3, 2018 13:32
累積分布関数を計算するための関数及びテスト用のコード。
package info.pandanote.normdist;
public class NormDistTest {
public double normDist(double x) {
if (x == 0.0) {
return 0.5;
}
double ax = x;
double deltaax = x;
@pandanote-info
pandanote-info / latex_equation_scroll.php
Created September 18, 2018 13:31
LaTeXの数式が画面からはみ出さないようにするための小細工用プログラム片。Wordpressの記事本文の処理用フィルタ関数の中でお使いください。
$content = preg_replace('/\\\\begin\{(align|eqnarray)/','<div class="tex-equations">\\begin{$1',$content);
$content = preg_replace('/\\\\end\{(align|eqnarray)(\*?)\}/','\\end{$1$2}</div>',$content);
@pandanote-info
pandanote-info / latex_equation_scroll.css
Created September 18, 2018 13:49
MathJax使用時にLaTeXの数式が画面からはみ出さないようにするための小細工用CSS片。
/* MathJax */
div.tex-equations {
overflow-x: auto;
}