Skip to content

Instantly share code, notes, and snippets.

@tohokuaiki
tohokuaiki / scrape-tleague-game-stat.php
Created October 23, 2019 08:36
Tリーグの試合結果からデータを一覧で取得
<?php
$urls=<<<EOF
https://tleague.jp/match/?season=2018&month=201810
https://tleague.jp/match/?season=2018&month=201811
https://tleague.jp/match/?season=2018&month=201812
https://tleague.jp/match/?season=2018&month=201901
https://tleague.jp/match/?season=2018&month=201902
https://tleague.jp/match/?season=2018&month=201903
https://tleague.jp/match/?season=2019&month=201910
https://tleague.jp/match/?season=2019&month=201911
@tohokuaiki
tohokuaiki / analysis_postfix_maillog.php
Created October 21, 2019 06:38
postfixのメールログを解析したくなった時にちょろっとPHPで
<?php
$lines = file('mail.log');
$logs = [];
$mails = [];
foreach ($lines as $k => $line){
$line = trim($line);
$cell = explode(" ", $line);
$status = $to = $from = '';
$size = 0;
@tohokuaiki
tohokuaiki / get_gitdiff.sh
Last active October 10, 2019 06:25
gitのcommitの差分をファイルに出す。削除ファイルの一覧付き。このファイルはgitリポジトリの直下に置く。SourceTreeのカスタムアクションのために作った。SourceTreeの For SourceTree custom action. 実行にはSourceTree\git_local\bin\bash.exeを使用。
ARCHIVE_INFO_FILE=archive_info.txt
DELETE_FILES_INFO=deleted_files.txt
T_TIME=`date "+%Y%m%d_%H%M%S"`
T_DAY=`date "+%Y%m%d"`
# $1に新しい方、$2に古い方のハッシュ
if [ $# -ne 2 ]; then
echo "引数が不正です。コミットは2つ指定してください。" >&2
exit 1
fi
@tohokuaiki
tohokuaiki / make_difffiles.js
Created October 10, 2019 06:18
2つのディレクトリから差分ファイルをdiffして見つける。 $node make_difffiles.js --old old_dir --new new_dir --dest difffiles_destdir
const fs = require('fs');
const path = require('path');
const glob = require('glob');
const slash = require('slash');
var minimist = require("minimist");
var nowString = ()=> {
var d = new Date(),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
AJS.$((function($){
return function(){
// 添付ファイルのコメント欄を偽装する comment = "url|+|http://www.example.com<:>title|+|about this url"
var attachCommentDelimiter = '<:>';
var propertyDelimiter = '|+|';
var extraAttachComments = {
title: '使用論文名',
comment: 'コメント',
url: '論文URL'
};
<?php
use \FeedWriter\ATOM ;
date_default_timezone_set( "Asia/Tokyo" ) ;
require_once dirname(__FILE__)."/FeedWriter/Item.php" ;
require_once dirname(__FILE__)."/FeedWriter/Feed.php" ;
require_once dirname(__FILE__)."/FeedWriter/ATOM.php" ;
class AtlasFeed
@tohokuaiki
tohokuaiki / pathinfo.php
Created November 16, 2016 03:08
PHPのpathinfoの仕様、変わりすぎぃ!!
<?php
function pathinfo($f)
{
$ret = pathinfo($f);
if (!isset($ret['filename'])){
$filename = substr($f, strrpos($f, '/') + 1);
$filename = substr($filename, 0, strrpos($filename, '.'.$ret['extension']));
$ret['filename'] = $filename;
}
@tohokuaiki
tohokuaiki / array_merge_recursive.php
Last active November 16, 2016 03:06
配列を再帰的にMergeする。存在するキーだけ上書きし、存在しない場合はoriginを引き継ぐ
<?php
function array_merge_recursive(&$origin, $extend)
{
foreach ($extend as $e_key=>$e_value){
if (!array_key_exists($e_key, $origin)){
$origin[$e_key] = $e_value;
}
else {
if (!is_array($e_value)){
$origin[$e_key] = $e_value;
@tohokuaiki
tohokuaiki / pascalize_camelize_snake_case.php
Last active November 16, 2016 03:07
命名則のまんま。多分suinさんところのblogからもらった。
<?php
function pascalize($string){
$string = strtolower($string);
$string = str_replace('_', ' ', $string);
$string = ucwords($string);
$string = str_replace(' ', '', $string);
return $string;
}
@tohokuaiki
tohokuaiki / getFileList.php
Last active November 16, 2016 03:07
ディレクトリ以下の全てのファイルを列挙
<?php
function getFileList($dir, $list=array('dir'=> array(), 'file' => array()))
{
if (is_dir($dir) == false) {
return $list;
}
$dh = opendir($dir);
if ($dh) {