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 / yarpp-template-pandanote-sample.css
Created May 31, 2022 11:44
関連記事へのリンクのリストにAdSenseのインフィード広告を紛れ込ませるためのコードのためのCSSの設定。
.related-post {
display: inline-block;
}
a.related-post {
color: #1e3e8a
}
.related-post img {
float: left;
@pandanote-info
pandanote-info / yarpp-template-pandanote-sample.php
Last active May 31, 2022 11:41
YARPPプラグインによる関連記事へのリンクのリストにAdSenseのインフィード広告を紛れ込ませるためのコード。
<h2>Related Posts / 関連ページ</h2>
<?php if(have_posts()):?>
<div class="related-post-list">
<?php $adpos = 0; ?>
<?php while(have_posts()) : the_post(); ?>
<?php if ($adpos == 1): ?>
<!-- Insert your infeed ad -->
<?php endif; ?>
<a href="<?php the_permalink() ?>"
title="<?php the_title_attribute(); ?>"
@pandanote-info
pandanote-info / regexp_test.vba
Created May 27, 2022 01:37
正規表現を用いて文字列の置換を行うためのVBAのプログラム例
Sub regexp_test()
Dim reg As Object
Set reg = CreateObject("VBScript.RegExp")
reg.Global = True
reg.Pattern = "^([^\(]+)\(([^\)]+)\)"
Dim output As String
output = reg.Replace("京急1000形1890番台(Le Ciel)", "$2 $1")
Debug.Print output
End Sub
@pandanote-info
pandanote-info / ipfs.service
Last active May 4, 2022 13:10
IPFSのdaemonの起動用のサービスユニットファイルのコード例。
[Unit]
Description=Ipfs
After=network-online.target
[Service]
User=panda
WorkingDirectory=/home/panda
OOMScoreAdjust=-1000
ExecStart=/usr/local/bin/ipfs daemon --enable-gc --enable-namesys-pubsub
ExecStop=/usr/bin/pkill --signal SIGINT ipfs
[Install]
@pandanote-info
pandanote-info / mongodb_var_lib_nfs_fs.te
Created April 2, 2022 11:48
MongoDB用のType Enforcementファイルの作成例(var_lib_nfs_t用)。
module mongodb_var_lib_nfs 1.0;
require {
type mongod_t;
type var_lib_nfs_t;
class dir search;
class file { getattr read open };
}
#============= mongod_t ==============
@pandanote-info
pandanote-info / mongodb_sysctl_fs.te
Created April 2, 2022 11:40
MongoDB用のType Enforcementファイルの作成例(sysctl_fs_t用)。
module mongodb_sysctl_fs 1.0;
require {
type mongod_t;
type sysctl_fs_t;
class dir search;
class file { getattr read open };
}
#============= mongod_t ==============
@pandanote-info
pandanote-info / uploadToIpfs.js
Created March 25, 2022 08:18
POSTメソッドで受け取ったbodyからバイナリデータを取り出し、IPFSノードにアップロードするNode.jsのプログラムのプログラム片。
// See https://pandanote.info/?p=8723 for details.
import * as fs from 'fs';
import axios from 'axios';
import FormData from 'form-data';
function getBoundary(header) {
var tmpct = header['content-type'].split(/;/);
var boundary = tmpct.filter(function(e) {
return e.trim().startsWith("boundary=");
});
@pandanote-info
pandanote-info / nginx_growi.conf.example
Last active February 18, 2022 01:14
nginxでHTTPS接続のリクエストを受け付けて、GROWIに転送するためのnginxの設定例。
# ドル記号の前のバックスラッシュはpanda大学習帳(https://pandanote.info/)での表示用のものです。
# nginxの設定として使用する場合には、ドル記号の前のスラッシュは削除が必要です。
http {
(中略)
map \$remote_addr \$allowed {
~aa.bb.cc. allow;
~2aaa:bbbb:cccc:dd: allow;
pp.qqq.rr.s allow;
127.0.0.1 allow;
default deny;
@pandanote-info
pandanote-info / openvpn_start.sh
Created January 13, 2022 13:56
ASUSのTUF-AX5400のシェルプロンプトからOpenVPNを起動するためのシェルスクリプト。
#!/bin/sh
modprobe tun
cd /jffs/openvpn/conf
nohup /usr/sbin/openvpn --config client.conf 2>&1 >/dev/null &
@pandanote-info
pandanote-info / tfidf.py.sample
Created January 7, 2022 07:47
TF-IDFの計算用のサンプルコード片
# TF
aa = bow.copy()
np.set_printoptions(threshold=np.inf,formatter={'float': '{:.8f}'.format})
for i in range(0,dim[0]):
ar = bow.getrow(i)
rowsum = np.matrix.sum(ar.todense())
arr = ar/rowsum
aa[i] = arr
# IDF(ln)