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 / amazon_widget_sample.php
Last active October 16, 2018 14:22
Amazon product advertising APIを使ってWordpressのサイドバーにリンクを表示するためのサンプルコード。
<?php
function create_url($params,$aws_secret_key) {
// The region you are interested in
$endpoint = "webservices.amazon.co.jp";
$uri = "/onca/xml";
// Set current timestamp if not set
if (!isset($params["Timestamp"])) {
@pandanote-info
pandanote-info / total_characters_on_wordpress.sql
Last active September 27, 2017 13:50
WordPressに記事として書かれている文章のおおよその総文字数を求めるSQL文
-- WordPressに記事として書かれている文章のおおよその総文字数を求めるSQL文
-- なお、本SQL文を利用することにより得られた結果については責任は負いかねます。
select sum(char_length(regexp_replace(regexp_replace(regexp_replace(post_content,'<.+?>',''),'&.+?;','_'),'(\s+|\r\n|\n)','')))
as total from wp_posts where post_status = 'publish' and post_type = 'post';
@pandanote-info
pandanote-info / total_characters_on_wordpress_excluding_examples.sql
Created September 27, 2017 13:54
WordPressに記事として書かれている文章のうち、設定ファイル、プログラム例及びコマンドの出力結果などを除いた部分のおおよその総文字数を求めるSQL文
-- WordPressに記事として書かれている文章のうち、
-- 設定ファイル、プログラム例及びコマンドの出力結果などを除いた部分のおおよその総文字数を求めるSQL文
-- なお、本SQL文を利用することにより得られた結果については責任は負いかねます。
select sum(char_length(regexp_replace(regexp_replace(regexp_replace(regexp_replace(post_content,'(?s)<div class="code">((?!</div>).)*?</div>',''),'<.+?>',''),'&.+?;','_'),'(\s+|\r\n|\n)','')))
as total from wp_posts where post_status = 'publish' and post_type = 'post';
@pandanote-info
pandanote-info / wordpress_acl_example.conf
Created September 28, 2017 22:18
Apache httpdでIPアドレスやUserAgentでアクセス制御を行うための設定例
# Access is only allowed via local access
# Change this once configured
<Directory /usr/share/a>
AllowOverride Options
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
Require local
</IfModule>
@pandanote-info
pandanote-info / leaflettest.html
Last active November 25, 2018 11:08
Leafletで地図を表示するためのサンプルコード。
<html>
<head>
<title>An example of a map by leaflet.</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"
integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA=="
crossorigin=""></script>
<script type="text/javascript">
@pandanote-info
pandanote-info / simple_leaflet_demo.php
Created October 4, 2017 14:47
プラグインを使わずにHTTPS接続で運用されているWordpressの記事内にLeafletで地図を表示させるためのショートコードのサンプル。
<?php
/*
このコードを使用した結果に関しては、いかなる保証も行いませんので、
その点につきましてはあしからずご了承ください。
*/
$_simple_leaflet_demo_map_number = 0;
function simple_leaflet_demo($atts) {
global $_simple_leaflet_demo_map_number;
$atts = shortcode_atts(array(
@pandanote-info
pandanote-info / link_cache_sample.sql
Created October 28, 2017 04:11
Amazon Product Advertising APIを使った広告で、現在までに作成したものを蓄積するためのMariaDBのテーブルの作成用のSQL文のサンプル
@pandanote-info
pandanote-info / mediawiki_example.conf
Last active January 26, 2020 07:02
mediawiki.confの設定例。ローカル以外からのアクセスを制限しています。
# This is a sample configuration for a wiki instance located under
# /var/www/wiki and exposed as http://thishost/wiki. Please read
# /usr/share/doc/mediawiki/README.RPM on whether to use this
# instance or create copies of it.
# Alias /wiki/skins /usr/share/mediawiki/skins
# Alias /wiki /var/www/wiki
# If your DocumentRoot points into the wiki itself all that is needed is
@pandanote-info
pandanote-info / quicklatex-format.css.diff
Created November 20, 2017 14:12
WP-QuickLaTeXで表示される数式のうちで、長いものを横スクロールできるようにするためのpatch。
--- quicklatex-format.css.ORG 2017-11-19 15:59:10.197954451 +0900
+++ quicklatex-format.css 2017-11-19 16:36:40.229951065 +0900
@@ -19,7 +19,7 @@
padding:0px !important;
margin:0px !important;
vertical-align:middle !important;
- display:inline-block !important;
+ display:inline-block !important;
}
@pandanote-info
pandanote-info / moviefilelist.py
Last active March 21, 2018 05:29
YouTube Data API v3を用いてYouTubeにおけるID、タイトル名、ファイル名及び再生回数をJSONファイルに保存するプログラム
#!/usr/bin/python
import httplib2
import os
import sys
import json
import argparse
from apiclient.discovery import build
from oauth2client.client import flow_from_clientsecrets