Skip to content

Instantly share code, notes, and snippets.

Avatar

pandanote-info pandanote-info

View GitHub Profile
@pandanote-info
pandanote-info / Excel2SQLite3_Worksheet_BeforeRightClick.vba
Last active Nov 10, 2021
ExcelのシートからSQLite3のCREATE TABLE句が記述されたファイルを生成するためのExcelのアドインのThisWorkbookに記述するコード。
View Excel2SQLite3_Worksheet_BeforeRightClick.vba
Option Explicit
Public WithEvents CreateTableStatementForSQLite3 As Application
Private Sub Workbook_Open()
Set CreateTableStatementForSQLite3 = Application
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Set CreateTableStatementForSQLite3 = Nothing
@pandanote-info
pandanote-info / CountElement.java
Created May 22, 2021
配列の配列の要素数の総和を求めるメソッドをJava8のラムダ式を使わない場合と使った場合の2通りの方法で書いたプログラム。
View CountElement.java
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 Apr 24, 2021
Blenderでトーラスを切断したような立体をモデリングするためのPython3のプログラム。
View partial_torus_r0.py
#!/usr/bin/env python3
#
# See https://pandanote.info/?p=7456
#
import bpy
import bmesh
import math
@pandanote-info
pandanote-info / directproducttest2.json
Created Mar 5, 2021
直積集合を作成するための集合を定義したJSONファイルの例。
View directproducttest2.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 Feb 4, 2021
GROWIの起動・終了を実行するとともに、その際に稼働状況をリモートのMariaDBに作成したテーブルに書き込むためのshell script
View startgrowi.sh
#!/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 Feb 4, 2021
GROWI起動用のサービスユニットファイルのコード例。
View growi.service
[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
View ServerStatus.pm
#!/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 Jan 27, 2021
remoteのサーバの状態をpushするためのデータベース及びテーブルを作成するためのSQL文
View serverstatus.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 Jan 23, 2021
Excelファイルからデータの記述されているセルを読み出して、その一覧を表示するためのPython3のプログラム。
View dumpxlsxposandvalues.py
#!/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 Dec 9, 2020
matplotlibとProcessPoolExecutorを使用して動画用の画像を並列処理で作成するためのPython3のプログラム。
View freqreader.py
#!/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