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 / findmp4inuvdl.py
Created December 31, 2017 09:40
moviefilelist.pyを使って生成したJSONのスクリプトを読み込んで、ちょっとおしゃれなexoファイルを生成するためのPython3のプログラム。
#!/usr/bin/env python
import io
import os
import sys
import json
import subprocess
import codecs
import re
import math
@pandanote-info
pandanote-info / show_engines_result_with_mroonga.txt
Created January 13, 2018 07:48
Mroongaをインストールした後のshow enginesの実行結果。
MariaDB [(none)]> show engines;
+--------------------+---------+----------------------------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------------+--------------+------+------------+
| MRG_MyISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| SEQUENCE | YES | Generated tables filled with sequential values | YES | NO | YES |
| MyISAM | YES | MyISAM storage engine
@pandanote-info
pandanote-info / ComplexNumber.scala
Last active June 22, 2018 04:15
Scalaで複素数を扱うためのクラス。BreezeのComplexクラスの実装を参考にしています。
package info.pandanote.test
import scala.reflect.ClassTag
import scala.math._
package info.pandanote.test
import scala.reflect.ClassTag
import scala.math._
// BreezeのComplexクラスを元にして複素数を扱うためのクラスを書いてみました。
@pandanote-info
pandanote-info / ComplexNumberTest.scala
Last active May 1, 2018 10:43
複素数を扱うためのクラスの動作確認用のプログラム例です。
package info.pandanote.test
// Scalaで複素数を扱うためのテスト用のコード例です。
// このコードは無保証であり、使用したことよって得られる結果については一切保証いたしません。
// 詳細は以下のURLを参照いただけると幸いです。
// https://pandanote.info/?p=1849
object ComplexNumberTest {
def main(args: Array[String]): Unit = {
val a = ComplexNumber(-2,4)
@pandanote-info
pandanote-info / build.sbt
Created May 1, 2018 08:47
ScalaTestを使用するためのbuild.sbtの設定例。
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.5"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test"
logBuffered in Test := false
@pandanote-info
pandanote-info / ComplexNumberTestClass.scala
Created May 1, 2018 10:45
複素数を扱うためのScalaクラスに対するScalaTest用のテストファイルの記述例。
package info.pandanote.test
import org.scalatest.Assertions
import org.scalatest._
class ComplexNumberTest extends FlatSpec with Matchers {
"a" should "123" in {
val a = "123"
a should be("123")
}
@pandanote-info
pandanote-info / catchphrase-sample.conf
Last active November 7, 2018 13:06
https://pandanote.info/catchphrase へのアクセスをクライアントに知らせることなく、https://pandanote.info/index.php?page_id=1874 に転送するための設定。
RewriteEngine on
# その他の設定
# Redirection for "catchphrase".
RewriteRule ^/catchphrase[^/]*$ /index.php?page_id=1874 [L,QSA]
<LocationMatch /catchphrase>
Require all granted
</LocationMatch>
<Location />
@pandanote-info
pandanote-info / catchphrase-sample-301-redirect.conf
Last active November 7, 2018 13:06
https://pandanote.info/?page_id=1874 へのアクセスを https://pandanote.info/catchphrase へ301リダイレクトするための設定。
# Redirection for "catchphrase".
RewriteCond %{QUERY_STRING} ^((?:[^&]*&)*)page_id=1874&?(.*)$
RewriteRule ^.*$ /catchphrase?%1%2 [R=301,L]
@pandanote-info
pandanote-info / recolog-sample.php
Last active July 8, 2018 13:27
特定のURLが指定された場合に限りAmazonアソシエイトのMobile Popoverを表示するためのPHPのコード片。
function add_this_script_footer(){
if (is_mobile() && preg_match("#^/recolog#",$_SERVER['REQUEST_URI'])) {
?>
// ここにMobile Popoverのコードを挿入。
<?php
}
}
add_action('wp_footer', 'add_this_script_footer',999);
@pandanote-info
pandanote-info / Quaternion.scala
Last active December 1, 2023 09:56
Scalaで四元数を扱うためのオブジェクト(Quaternionオブジェクト)及びクラス(Quaternionクラス)の実装例。
package info.pandanote.test
import scala.reflect.ClassTag
import scala.math._
// A class to represent and to handle a quaternion.
// 四元数を扱うためのクラスを書いてみました。
case class Quaternion(real: Double, _i: Double, _j: Double, _k: Double) {
override def toString(): String = real + (if (_i == 0.0) "" else ((if (_i>0.0)"+"else"-")+(if (_i>0.0)_i else -_i) + "i")) + (if (_j == 0.0) "" else ((if (_j>0.0)"+"else"-")+(if (_j>0.0)_j else -_j) + "j")) + (if (_k == 0.0) "" else ((if (_k>0.0)"+"else"-")+(if (_k>0.0)_k else -_k) + "k"))