Skip to content

Instantly share code, notes, and snippets.

View yousan's full-sized avatar
💻
I must work everyday

Yousan_O yousan

💻
I must work everyday
View GitHub Profile
@yousan
yousan / uuid_to_fstab.sh
Last active June 13, 2018 13:15
uuid to fstab
#!/bin/bash
# UUID=1234-37bd-4098-9f8b-85e99c9c5219 /boot xfs defaults 0 0
blkid | grep $1 | sed -r 's#^.*UUID="([a-Z0-9\-]+)".*TYPE="([a-Z0-9\-]+)".*$#UUID=\1\t'$2'\t\2\tdefaults\t0\t0#'
@yousan
yousan / sec.php
Last active September 24, 2017 08:07
my wordpress might be hacked
<?php
/**
* Provides a block to display 'Site branding' elements.
*
* @Block(
* id = "system_branding_block",
* admin_label = @Translation("Site branding")
* )
*/
@yousan
yousan / composer.json
Created June 8, 2017 04:40
Install WordPress with composer
{
"require": {
"php": ">=5.4",
"johnpbloch/wordpress": "4.7.5"
},
"extra": {
"wordpress-install-dir": "public/wp"
},
"post-install-cmd": {
<?php
/**
* Smart Custom Fieldsの定義用クラス
* グループごとにメソッドを作ると良い
*
* @link https://2inc.org/blog/2015/03/12/4670/
*/
Class Test_SmartCustomFields {
#!/usr/bin/env bash
if [ $# -lt 3 ]; then
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
exit 1
fi
DB_NAME=$1
DB_USER=$2
DB_PASS=$3
// https://codex.wordpress.org/Transients_API
// kショートコードをsキャッシうュるコード
add_shortcode('someshortcode', function() {
echo 'hoge';
});
add_shortcode('someshortcode_cached', function() {
if ( $ret = get_transient('someshortcode') ) {
return $ret;
<?php
if ( ! class_exists( 'RecommendPost' ) ) {
class RecommendPost {
static function init() {
add_action( 'admin_menu', array( __CLASS__, 'add_meta_box' ) );
add_action( 'save_post', array( __CLASS__, 'save_meta_data' ) );
add_action( 'pre_get_posts', array( __CLASS__, 'change_order' ) );
}
#!/usr/bin/env bash
# @see http://qiita.com/miya0001/items/4dc5949dd792963ef578 Thanks!
# Usage: ssh user@example.com
# Automatically adds `-i user@example.com` argument for `ssh` command.
# test: bash -c 'source ssh_bash.bash; ssh user@example.com ls'
function ssh {
local HOSTSTR
@yousan
yousan / dget
Last active June 28, 2016 06:23
#!/bin/sh
if [ $# -ne 1 ]; then
echo "warn: need a url"
exit 1
fi
#正体はただのaliasでした!
wget --no-host-directories -r -np $1
<?php
// 年度が始まる日
define('ANNUAL_START_DAY', '04-02');
/**
* 「年度」を取得する
*
*/
function get_annual_year(DateTime $date) {