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 / 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"))
@pandanote-info
pandanote-info / pandanote-copyright.js
Created January 12, 2023 14:39
Copyright表示の年号部分をアクセスした年に応じて調整してくれるだけのWeb Components
@pandanote-info
pandanote-info / exo2srt.py
Last active September 3, 2023 15:20
AviUtlのエキスポートファイルから字幕ファイル(srt)ファイルを作成するためのコード
#!/usr/bin/env python3
# coding: utf-8
#
# See https://pandanote.info/?p=29 for details.
#
import io
import sys
import re
import codecs
@pandanote-info
pandanote-info / adjust_config_sample.sh
Last active April 30, 2023 08:30
Fedora+nginxのアップデートまたはアップグレードを行う際に、nginx用の設定ファイルのownerをnginxユーザに戻すためのシェルスクリプト。
#!/bin/sh
# See https://pandanote.info/?p=8118 for details.
chown -R nginx /etc/wordpress
chown -R nginx /var/lib/php/session
chown -R nginx /var/lib/php/wsdlcache/
chown -R nginx /var/lib/php/opcache/
chown -R nginx /usr/share/wordpress/wp-content/uploads/
chown nginx:nginx /var/log/nginx
@pandanote-info
pandanote-info / constructor_override.py
Created December 23, 2022 13:07
classmethodデコレータを使ったコンストラクタのオーバーライドの例
# See https://pandanote.info/?p=9956 for details.
class Expense:
amount = 0
reason = ""
remark = ""
def __init__(self, amount, reason, remark):
self.amount = amount
self.reason = reason
self.remark = remark
@pandanote-info
pandanote-info / drop_file_with_blob_and_promise.js
Last active November 5, 2022 04:03
ファイルをWebブラウザにドラッグ&ドロップするためのVue.js用のメソッド(Blob及びPromise使用)
// Inside a Vue instance...
dragOver(event) {
event.preventDefault();
},
dropFile(event) {
event.preventDefault(); dropFile() {
if (event.dataTransfer.files.length != 1) {
alert("Only one file can be dropped");
return;
}
@pandanote-info
pandanote-info / dropfile_with_filereader.js
Last active November 5, 2022 04:03
ファイルをWebブラウザにドラッグ&ドロップするためのVue.js用のメソッド(FileReader使用)
// Inside a Vue instance...
dragOver(event) {
event.preventDefault();
},
dropFile(event) {
event.preventDefault();
if (event.dataTransfer.files.length != 1) {
alert("Only one file can be dropped");
return;
}
@pandanote-info
pandanote-info / datetime_in_isoformat_part2.py
Created August 28, 2022 11:40
現在のローカル時刻をISO8601フォーマットで表示するためのPython3のプログラム(その2)。
#!/usr/bin/python
#
# See https://sidestory.pandanote.info/datetime_in_iso8601.html
#
from datetime import datetime
print(datetime.now().astimezone().isoformat())
@pandanote-info
pandanote-info / datetime_in_isoformat_part1.py
Created August 28, 2022 11:39
現在のローカル時刻をISO8601フォーマットで表示するためのPython3のプログラム(その1)。
#!/usr/bin/python
#
# See https://sidestory.pandanote.info/datetime_in_iso8601.html
#
import datetime
print(datetime.datetime.now().astimezone().isoformat())
@pandanote-info
pandanote-info / CountElement.java
Created May 22, 2021 14:45
配列の配列の要素数の総和を求めるメソッドをJava8のラムダ式を使わない場合と使った場合の2通りの方法で書いたプログラム。
package info.pandanote.test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class CountElement {