バルクアップデート、バルク=大量

2023.10.01

Logging

おはようございます、バルクアップデートという技を最近知りました。バルクとは大量を意味する言葉です、バルクアップデートとは大量のデータを一括でアップデートする手法です。結構、大量のデータをアップデート出来るのですが、それでも時間がかかります。因みに普通にアップデートすると「504 Gateway Timeout 」が発生する場合などに使用する良いと思います。

これでもUPDATEが出来ない場合は、一度、クラウドに一旦保存しておき、そこから再度、更新処理を行うと言った手法が良いかも知れません。何にせよ、大量のデータを一括アップデートは大変です。

Xのシェアしたものを貼り付けていますが、見れない人用にリンクも貼っときます。

https://gri.jp/media/entry/9838

明日へつづく😌。

タグ

Gateway Timeout, UPDATE, X, アップ, アップデート, クラウド, データ, バルク, バルクアップデート, リンク, 一括, 一括アップデート, 一旦, 再度, 大量, 手法, , 時間, 更新処理, 言葉,

編集エディタにYOUTUBEのshortのURLを貼り付けても変換されないを改善。 #プラグイン

2023.05.17

Logging

おはようございます。編集エディタにYOUTUBEのshortのURLを貼り付けても変換されないのを改善する方法1ですがコアなPHPファイルを編集することになりますので、動作しなくなったとかは補償はしません、自己責任でお願い致します。YOUTUBEのshortのURLを貼り付けても変換されないのは、WordPressがそのコード一行を未だに追加してくれないから単なるリンクに変換されるだけであるということです。

砂浜Tシャツアート展2023

やり方はこんな感じです。下記のWordPressのファイルを開きます。$providersの配列に一行追加してあげるだけです。但しUPDATEが走る度にWordPressを確認しないといけないので自己責任でお願い致します。そのうち、WordPressの公式が解決してくれると思います。

wp-includes\class-wp-oembed.php
$providers = array(
'#https?://www.youtube.com/shorts/.*#i'        => array( 'https://www.youtube.com/oembed', true ),

この方法の他にURLを貼り付けたときにJSコードでURLを変換する方法や変換する瞬間に関数にフックする方法もありかと思います。そちらの方がWordPressのバージョンがUPしても気にしなくて良いし安全かと思います。

追伸:プラグインにしてみました。ソースコードはこちらです。

/*
Plugin Name: youtube-shorts
Plugin URI: https://zip358.com/
Description: youtube-shorts
Version: 1.0
Author: taoka-toshiaki
Author URI: youtube-shortsを貼り付け出来るように
*/
add_filter(
    'oembed_providers',
    function ($providers) {
        $providers['#https?://www.youtube.com/shorts/.*#i'] = array('https://www.youtube.com/oembed', true);
        return $providers;
    },
    1,
    1
);

タグ

$providers, add_filter, array, description, function, oembed_providers, PHPファイル, return, short, taoka-toshiaki Author, true, UPDATE, URI, wp-includesclass-wp, youtube, youtube-shorts, youtube-shorts Plugin, youtube-shorts Version, 追伸, 配列,

Bardが徐々に改善されてきている。#酷評した人

2023.04.29

Logging

おはようございます、ここ数日でBardが徐々に改善されてきています、UPDATEも走っているのですが、それ以外にも細かなUPDATEが走っていると思います。あとは日本語に対応すればGさんからchatGPTを使用しなくてもGさんで完結しそうな気がします。

そろそろ、片言の日本語で良いのでリリースして頂いて後からUPDATEしながら良い方向に進んでもらいたいです。それが出来ないのか分からないけれど、今回、Gさんは慎重になりすぎている気がします。

個人的には一兆円失ってもリリースすべきだと思います。

これ完璧なものを期待していないと思うですよね、それよりか使い勝手の良い人工知能をリリースして欲しい。もしくはchatGPTの模倣で良いので、GさんのAIツールをリリースしてほしい、この調子だと正式リリースは今季か来年になりそうな気がします。

タグ

AIツール, Bard, ChatGPT, Gさん, UPDATE, リリース, 一兆円, 今季か来年, 使い勝手, 数日, 日本語, 模倣, 欲しい。, 正式リリース, , 片言, 良い人工知能, 良い方向, 調子,

Twitter-API-v2ツイート数珠繋ぎ #コード公開 #php

2022.10.04

Logging

おはようございます。土日祝も関係なくブログは毎日書いています🤮。

さて、今日はPHP言語でTwitterAPIバージョン2(v2)を使用してツイート数珠繋ぎをする方法を抜粋して記載していきます。こういうコードは今のところ出回っていないようです。少し調べれば公式サイトに記載しているのだけども・・・。まだ、日本語に対応した記事が少ないようです。v2でツイートする方法やリツイートする方法は何故かあるのだけどリプライ(Reply)[/statuses/update]する方法が記事としては記載していなかったので?記載します。

<?php
require_once "vendor/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;

class tw{
    var $connection = null;
    function __construct()
    {
        $this->connection = new TwitterOAuth(APIKEY, APISECRET,ACCESSTOKEN, ACCESSTOKENSECRET);
        $this->connection->setApiVersion("2");
    }

    function pickup_tweets(mixed $tw_text=null){
         $obj = (object)[];
        if(isset($tw_text) && is_array($tw_text)){
            foreach ($tw_text as $key => $value) {
                if(preg_replace("/[ | ]/","",$value)){
                    $obj = !$key?(
                        $this->connection->post("tweets", ["text" =>$value], true)
                    ):
                    (
                        $this->connection->post("tweets", ["reply"=>["in_reply_to_tweet_id"=>$obj->data->id],"text"=> $value], true)
                    );
                }
            }
            return true;
        }
        return false;
    }
}

最初に結論とコードのアルゴリズムに付いて解説します。まず、tweetsのパラメーターでリプライ出来るように変更されています。v1.1とはそこが変わっているので同じ仕組みを検索しがちですがそれでは検索にヒットしないようです🤔。まずはエンドポイントの変更点の確認が必要みたい👏。

エンドポイントのv1.1からv2への対応表

エンドポイントのv1.1からv2への対応表が公式から出ているので確認してみてください↑。

次にコードの解説ですがまずTwitterOAuthライブラリをインストールを行い、defineなどの設定なども考慮した上で実行してみてください(コードに追記記載が必要)。変数、$tw_textは配列です。また投稿する文字が入っていると考えてください。そしてこのコードを下記のような考え方で実行してみてください。

<?php
       require_once "tw-index.php";
       $tw_text[0] ="test1";
       $tw_text[1] ="test2";
       $tw = new tw();
       if($tw->pickup_tweets($tw_text)){
        $ret["msg"] = "ok";
       }else{
        $ret["msg"] = "NG";
       }
       var_dump($ret);

※前提条件としてtwitter社にAPIの申請を行って受理されている事。

Twitter API v2 ツイート数珠繋ぎ

これで思った通り実行出来たと思います。尚、自分のように管理画面などを作って数珠繋ぎの投稿するのも良いかも知れません🫠。

タグ

2, Abraham, autoload, class, connection, function, lt, null, once, php, quot, Reply, require, statuses, tw, Twitter-API-v, TwitterAPI, TwitterOAuth, UPDATE, use, var, vendor, コード, サイト, ツイート, ところ, バージョン, ブログ, リツイート, リプライ, , 今日, 使用, 公式, 公開, 土日, 対応, 少し, 抜粋, 数珠繋ぎ, 方法, 日本語, 毎日, , 言語, 記事, 記載,

VirtualBoxで共有フォルダ設定とApacheが表示されるまで。

2020.11.29

Logging

前処理としてこのコマンドを打つ。

yum -y groupinstall "Development Tools"
yum -y update kernel
yum -y install kernel-devel kernel-headers gcc gcc-c++

起動したらメニューから[デバイス]-[Guest Additions CDイメージの挿入]

mount /dev/cdrom /mnt
cd /mnt
./VBoxLinuxAdditions.run

reboot
cd /var/www/
ln -s マウント先 sf_html
gpasswd -a oreore vboxsf
gpasswd -a apache vboxsf

mount -t vboxsf -o dmode=0755,fmode=0755 (共有名) (マウント先)

reboot

Apacheのconfig設定ではリンク先はシンボルリンクを参照させとこう、これでリブートさせて完了やねん。さてこれで理解できたら、あなたは凄いです。これは単なるメモ書き記載なので、わからないと思います。

なので、参考にしたサイトのリンクを貼っときます。
http://itemy.net/?p=1355
https://www.codelab.jp/blog/?p=2587

これらでおそらく大体の人が理解できたと思います。

タグ

-o, -s, -t, -y, 0755, A`, Additions, Apache, cd, cdrom, dev, Development, dmode, fmode, gcc, gcc-c, gpasswd, groupinstall, Guest, html, install, kernel, kernel-devel, kernel-headers, ln, mnt, mount, oreore, quot, reboot, run, SF, Tools, UPDATE, var, VBoxLinuxAdditions, vboxsf, virtualBOX, www, yum, イメージ, コマンド, デバイス, フォルダ, マウント, メニュー, 共有, 前処理, 挿入, 表示, 設定, 起動,

WordPressの公式ウィジェットカレンダー末日がズレている?ので直した。

2020.11.02

Logging

WordPressの公式ウィジェットカレンダー末日がズレている?ので直した。直した箇所はこちら変数名に$ooooと書いている部分が今回修正した箇所です。修正したファイルはWordPressのインクルードフォルダにある。ジェネラルテンプレートぴーえぃちーぴー(general-template.php)

wp-includes\general-template.php 

このファイルを直しました。コアファイルなので次期UPDATEで修正されるかとは思いますが、それまではこちらの修正でなんとかなるさ?!

因みに何故、$ooooにしたのかは、お???の???という土佐弁からです。ファイルの中にget_calendar(げっとカレンダー)という関数があるのでそちらを修正しています。原因は下記です。
gmdateというものを使用している所をローカルサーバーの時間で対応しました、さくらレンタルサーバーのタイムゾーンは日本時間を指しています。若干の誤差はあるけれど酷い誤差ではないのでdateで大丈夫そうです。

要は日付の末日が正確に取れていないことが原因みたいです?
はやく修正してくれることを願っています。

function get_calendar( $initial = true, $echo = true ) {
	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;

	$key   = md5( $m . $monthnum . $year );
	$cache = wp_cache_get( 'get_calendar', 'calendar' );

	if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) {
		/** This filter is documented in wp-includes/general-template.php */
		$output = apply_filters( 'get_calendar', $cache[ $key ] );

		if ( $echo ) {
			echo $output;
			return;
		}

		return $output;
	}

	if ( ! is_array( $cache ) ) {
		$cache = array();
	}

	// Quick check. If we have no posts at all, abort!
	if ( ! $posts ) {
		$gotsome = $wpdb->get_var( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
		if ( ! $gotsome ) {
			$cache[ $key ] = '';
			wp_cache_set( 'get_calendar', $cache, 'calendar' );
			return;
		}
	}

	if ( isset( $_GET['w'] ) ) {
		$w = (int) $_GET['w'];
	}
	// week_begins = 0 stands for Sunday.
	$week_begins = (int) get_option( 'start_of_week' );

	// Let's figure out when we are.
	if ( ! empty( $monthnum ) && ! empty( $year ) ) {
		$thismonth = zeroise( intval( $monthnum ), 2 );
		$thisyear  = (int) $year;
	} elseif ( ! empty( $w ) ) {
		// We need to get the month from MySQL.
		$thisyear = (int) substr( $m, 0, 4 );
		// It seems MySQL's weeks disagree with PHP's.
		$d         = ( ( $w - 1 ) * 7 ) + 6;
		$thismonth = $wpdb->get_var( "SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')" );
	} elseif ( ! empty( $m ) ) {
		$thisyear = (int) substr( $m, 0, 4 );
		if ( strlen( $m ) < 6 ) {
			$thismonth = '01';
		} else {
			$thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 );
		}
	} else {
		$thisyear  = current_time( 'Y' );
		$thismonth = current_time( 'm' );
	}

	$unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear );
	$last_day  = gmdate( 't', $unixmonth );
	$oooothisyear  = date( 'Y', $unixmonth  );
	$oooolast_day  = date( 't', $unixmonth );
	$oooothismonth = date( 'm' , $unixmonth);

	// Get the next and previous month and year with at least one post.
	$previous = $wpdb->get_row(
		"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
		FROM $wpdb->posts
		WHERE post_date < '$thisyear-$thismonth-01'
		AND post_type = 'post' AND post_status = 'publish'
			ORDER BY post_date DESC
			LIMIT 1"
	);
	$next     = $wpdb->get_row(
		"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
		FROM $wpdb->posts
		WHERE post_date > '$oooothisyear-$oooothismonth-{$oooolast_day} 23:59:59'
		AND post_type = 'post' AND post_status = 'publish'
			ORDER BY post_date ASC
			LIMIT 1"
	);

	/* translators: Calendar caption: 1: Month name, 2: 4-digit year. */
	$calendar_caption = _x( '%1$s %2$s', 'calendar caption' );
	$calendar_output  = '<table id="wp-calendar" class="wp-calendar-table">
	<caption>' . sprintf(
		$calendar_caption,
		$wp_locale->get_month( $thismonth ),
		gmdate( 'Y', $unixmonth )
	) . '</caption>
	<thead>
	<tr>';

	$myweek = array();

	for ( $wdcount = 0; $wdcount <= 6; $wdcount++ ) {
		$myweek[] = $wp_locale->get_weekday( ( $wdcount + $week_begins ) % 7 );
	}

	foreach ( $myweek as $wd ) {
		$day_name         = $initial ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
		$wd               = esc_attr( $wd );
		$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
	}

	$calendar_output .= '
	</tr>
	</thead>
	<tbody>
	<tr>';

	$daywithpost = array();

	// Get days with posts.
	$dayswithposts = $wpdb->get_results(
		"SELECT DISTINCT DAYOFMONTH(post_date)
		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
		AND post_type = 'post' AND post_status = 'publish'
		AND post_date <= '{$oooothisyear}-{$oooothismonth}-{$oooolast_day} 23:59:59'",
		ARRAY_N
	);

	if ( $dayswithposts ) {
		foreach ( (array) $dayswithposts as $daywith ) {
			$daywithpost[] = (int) $daywith[0];
		}
	}

	// See how much we should pad in the beginning.
	$pad = calendar_week_mod( gmdate( 'w', $unixmonth ) - $week_begins );
	if ( 0 != $pad ) {
		$calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr( $pad ) . '" class="pad">?</td>';
	}

	$newrow      = false;
	$daysinmonth = (int) gmdate( 't', $unixmonth );
	$oooodaysinmonth = (int) date( 't', $unixmonth );

	for ( $day = 1; $day <= $oooodaysinmonth; ++$day ) {
		if ( isset( $newrow ) && $newrow ) {
			$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
		}
		$newrow = false;

		if ( current_time( 'j' ) == $day &&
			current_time( 'm' ) == $thismonth &&
			current_time( 'Y' ) == $thisyear ) {
			$calendar_output .= '<td id="today">';
		} else {
			$calendar_output .= '<td>';
		}

		if ( in_array( $day, $daywithpost, true ) ) {
			// Any posts today?
			$date_format = gmdate( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
			/* translators: Post calendar label. %s: Date. */
			$label            = sprintf( __( 'Posts published on %s' ), $date_format );
			$calendar_output .= sprintf(
				'<a href="%s" aria-label="%s">%s</a>',
				get_day_link( $thisyear, $thismonth, $day ),
				esc_attr( $label ),
				$day
			);
		} else {
			$calendar_output .= $day;
		}

		$calendar_output .= '</td>';

		if ( 6 == calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
			$newrow = true;
		}
	}

	$pad = 7 - calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins );
	if ( 0 != $pad && 7 != $pad ) {
		$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr( $pad ) . '">?</td>';
	}

	$calendar_output .= "\n\t</tr>\n\t</tbody>";

	$calendar_output .= "\n\t</table>";

	$calendar_output .= '<nav aria-label="' . __( 'Previous and next months' ) . '" class="wp-calendar-nav">';

	if ( $previous ) {
		$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">? ' .
			$wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
		'</a></span>';
	} else {
		$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-prev">?</span>';
	}

	$calendar_output .= "\n\t\t" . '<span class="pad">?</span>';

	if ( $next ) {
		$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
			$wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
		' ?</a></span>';
	} else {
		$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-next">?</span>';
	}

	$calendar_output .= '
	</nav>';

	$cache[ $key ] = $calendar_output;
	wp_cache_set( 'get_calendar', $cache, 'calendar' );

	if ( $echo ) {
		/**
		 * Filters the HTML calendar output.
		 *
		 * @since 3.0.0
		 *
		 * @param string $calendar_output HTML output of the calendar.
		 */
		echo apply_filters( 'get_calendar', $calendar_output );
		return;
	}
	/** This filter is documented in wp-includes/general-template.php */
	return apply_filters( 'get_calendar', $calendar_output );
}

タグ

calendar, general-template, GET, gmdate, oooo, php, UPDATE, WordPress, wp-includes, インクルード, ウィジェット, カレンダー, コア, こちら, サーバー, さくら, ジェネラル, ズレ, そちら, それまで, タイム, テンプレート, ファイル, フォルダ, もの, レンタル, ローカル, 下記, , 今回, 使用, 修正, 公式, 原因, 土佐弁, 変数, 対応, , 時間, 末日, 次期, 箇所, 部分, 関数,

あっ!この人、賢いなと思った人。

2020.05.18

Logging

NewsPicksのUPDATE(アップデート)『未曾有のエンタメ危機をどう救うか?』番組を見ていて佐渡島庸平さんが話していた、567が終わった後どうなるかという事が結構為になるなと思いました。やはり過去どうなっていったのか、そして今と過去を掛け合わせて未来を予想するのに長けているなと思えたひとですね。

「日本のエンタメをどう救うか?」をブシロード 創業者 木谷高明、明石ガクトらと徹底討論

YOUTUBEでは佐渡島庸平さんが話ししている所まで尺がないので有料会員しか見えないようになっています。興味がある方は見てみるべしかな、、。特にエンタメがどうなるかの予想は面白かったです。そして司会者の古坂大魔王さんが最初と最後に同じ内容を語っているの事があるのだけど。それはホントそうだよなと思えました。

タグ

567, newspicks, UPDATE, youtube, アップデート, エンタメ, それ, ホント, 予想, , , , 会員, 佐渡島, 内容, 危機, 古坂大魔王, 司会者, , 庸平, , , , 最初, 最後, 有料, 未曾有, 未来, , 番組, 興味, 過去,