Skip to content

Instantly share code, notes, and snippets.

View kurozumi's full-sized avatar

kurozumi kurozumi

View GitHub Profile
@kurozumi
kurozumi / FileUploader.php
Created February 25, 2019 08:40
FileUploader Service
<?php
namespace App\Service;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* Description of FileUploader
*
@kurozumi
kurozumi / thumbnails.php
Last active December 27, 2018 07:05
【WordPress】画像サイズを登録する
<?php
/*
* アイキャッチ画像を有効化
*/
add_theme_support('post-thumbnails');
/*
* 画像サイズ登録
* [width, height, [true|false|array]]
@kurozumi
kurozumi / LineAuthenticator.php
Created December 17, 2018 13:35
SymfonyでLineログイン
<?php
namespace App\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
@kurozumi
kurozumi / wp-media.php
Created October 30, 2018 08:57
WP REST API v2で画像投稿
<?php
require_once( dirname( __FILE__ ) . '/wp-load.php' );
// APIエンドポイントのURL
$url = 'http://sample.com/wp-json/wp/v2/media';
// ユーザー名(Application Passwordsプラグインでパスワードを発行したユーザーのもの)
$username = 'test';
// パスワード(Application Passwordsプラグインで発行されたパスワード)
@kurozumi
kurozumi / api-post.php
Last active October 30, 2018 09:49
WP REST API v2で新規投稿
<?php
require_once( dirname( __FILE__ ) . '/wp-load.php' );
// APIエンドポイントのURL
$url = 'http://sample.com/wp-json/wp/v2/posts';
// ユーザー名(Application Passwordsプラグインでパスワードを発行したユーザーのもの)
$username = 'test';
// パスワード(Application Passwordsプラグインで発行されたパスワード)
@kurozumi
kurozumi / datepicker.js
Created October 10, 2018 02:53
Datepickerの日付に数字を追加する
<html>
<head>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
var stocks = {"2018\/10\/11":13,"2018\/10\/12":10,"2018\/10\/13":10,"2018\/10\/14":10,"2018\/10\/15":10,"2018\/10\/16":11,"2018\/10\/17":11,"2018\/10\/18":11,"2018\/10\/19":12,"2018\/10\/20":12,"2018\/10\/21":12,"2018\/10\/22":12,"2018\/10\/23":15,"2018\/10\/24":16,"2018\/10\/25":15,"2018\/10\/26":15,"2018\/10\/27":15,"2018\/10\/28":17,"2018\/10\/29":17,"2018\/10\/30":17,"2018\/10\/31":17,"2018\/11\/1":17,"2018\/11\/2":17,"2018\/11\/3":17,"2018\/11\/4":17,"2018\/11\/5":17,"2018\/11\/6":18,"2018\/11\/7":18,"2018\/11\/8":19,"2018\/11\/9":19,"2018\/11\/10":19,"2018\/11\/11":19,"2018\/11\/12":19,"2018\/11\/13":19,"2018\/11\/14":20,"2018\/11\/15":"21","2018\/11\/16":"21","2018\/11\/17":"21","2018\/11\/18":"21","2018\/11\/19":"21","2018\/11
@kurozumi
kurozumi / gist:bacefca0f26bff619dadbc6053ffc7ac
Created September 26, 2018 04:37
Custom Post Type Permalinksプラグインを使ったときのカスタムタクソノミーのURLをきれいにする方法
// カスタム投稿のスラッグはnewsとする
// カスタム投稿タイプのパーマリンクを/%news_category%/post-%post_id%/と設定
// ニュースカテゴリ用に新しいルールを追加
add_filter('rewrite_rules_array', function($rules){
$newrules = array();
$newrules['news/([^/]+)/?$'] = 'index.php?post_type=news&news_category=$matches[1]';
$newrules['news/([^/]+)/page/([0-9]+)/?$'] = 'index.php?post_type=news&news_category=$matches[1]&paged=$matches[2]';
return $newrules + $rules;
});
@kurozumi
kurozumi / python-wardwrap.ipynb
Created March 8, 2018 06:40
PythonでPHPのwordwrap関数のように指定した文字数で文字列を分割する方法
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kurozumi
kurozumi / python-array-slice.ipynb
Created March 8, 2018 06:30
PythonでPHPのarray_slice関数のように配列の一部を展開する方法
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kurozumi
kurozumi / python-array_reverse.ipynb
Created March 8, 2018 06:20
PythonでPHPのarray_reverse関数のように配列の要素を逆順にする方法
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.