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 / 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 {
@pandanote-info
pandanote-info / partial_torus_r0.py
Created April 24, 2021 11:24
Blenderでトーラスを切断したような立体をモデリングするためのPython3のプログラム。
#!/usr/bin/env python3
#
# See https://pandanote.info/?p=7456
#
import bpy
import bmesh
import math
@pandanote-info
pandanote-info / directproducttest2.json
Created March 5, 2021 13:55
直積集合を作成するための集合を定義したJSONファイルの例。
{
"key1": ["a1","a2","a3"],
"key2": ["b1","b2","b3","b4"],
"key3": ["c1","c2","c3","c4","c5"],
"key4": ["d1","d2","d3","d4","d5","d6"],
"key5": ["e1","e2","e3"],
"key6": ["f1","f2","f3"],
"key7": ["a1","a2","a3"],
"key8": ["b1","b2","b3","b4"],
"key9": ["c1","c2","c3","c4","c5"],
@pandanote-info
pandanote-info / startgrowi.sh
Last active February 4, 2021 13:37
GROWIの起動・終了を実行するとともに、その際に稼働状況をリモートのMariaDBに作成したテーブルに書き込むためのshell script
#!/bin/bash
#
# See https://pandanote.info/?p=7259 for details.
#
MODE="start"
SERVER="192.168.11.11"
if [ -n "$1" ]; then
MODE="stop"
fi
@pandanote-info
pandanote-info / growi.service
Created February 4, 2021 13:15
GROWI起動用のサービスユニットファイルのコード例。
[Unit]
Description=Growi
After=network-online.target mongod.service mariadb.service openvpn-client@client.service
[Service]
WorkingDirectory=/opt/wiki/growi
EnvironmentFile=/etc/sysconfig/growi
ExecStart=/bin/bash /opt/wiki/startgrowi.sh
ExecStop=/bin/bash /opt/wiki/startgrowi.sh stop
[Install]
WantedBy=multi-user.target
#!/usr/bin/perl
# See https://pandanote.info/?p=7242 for details.
package ServerStatus;
use strict;
use warnings;
use DBI;
sub getStatus {
my $dbh = DBI->connect('DBI:MariaDB:database=serverstatus;host=localhost',
@pandanote-info
pandanote-info / serverstatus.sql
Last active January 27, 2021 10:20
remoteのサーバの状態をpushするためのデータベース及びテーブルを作成するためのSQL文
-- See https://pandanote.info/?p=7242 for details.
drop database if exists serverstatus;
create database serverstatus;
grant all privileges on serverstatus.* to 'serverstatus'@'%' identified by 'Some password to store the status of the remote server.';
grant all privileges on serverstatus.* to 'serverstatus'@'localhost' identified by 'Some password to store the status of the remote server.';
use serverstatus;
drop table if exists serverstatus;
create table serverstatus (
id int not null auto_increment,
status int not null,
@pandanote-info
pandanote-info / dumpxlsxposandvalues.py
Created January 23, 2021 07:41
Excelファイルからデータの記述されているセルを読み出して、その一覧を表示するためのPython3のプログラム。
#!/usr/bin/python3
#
# See https://pandanote.info/?p=7224 for details.
#
import io
import sys
import os
import argparse
import openpyxl
@pandanote-info
pandanote-info / freqreader.py
Last active December 9, 2020 23:19
matplotlibとProcessPoolExecutorを使用して動画用の画像を並列処理で作成するためのPython3のプログラム。
#!/usr/bin/python3
#
# See https://pandanote.info/?p=6970 for details.
#
import datetime
import math
import json
import numpy as np
from scipy.sparse import lil_matrix
import io, sys
@pandanote-info
pandanote-info / insert-timestamp-for-githubpages-for-markdown.el
Created November 8, 2020 09:18
GitHub Pages用のmarkdownファイルに"update:"という行が現れたら、markdownファイルの保存時にそれらのうちの最初の行に最終更新日時を追加するためのEmacs Lispのプログラム。
;; See https://pandanote.info/?p=6871 for details.
(defun insert-timestamp-for-githubpages ()
"Insert time stamp into the line starting from \"update: \"."
(interactive)
(goto-char 0)
(if (re-search-forward "^update:.*$" nil t)
(replace-match (concat "update: " (current-time-string) " " (format-time-string "%z"))))
)
(defun insert-timestamp-for-githubpages-for-markdown ()