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 / file0.txt
Last active August 29, 2015 14:16
今風にUbuntuにGitの公開サーバを立てた ref: http://qiita.com/yousan/items/d102833d867972fbed6d
sudo aptitude install git apache22 gitweb
@yousan
yousan / file0.txt
Last active August 17, 2020 03:57
Macを使う新人エンジニアに絶対に覚えてもらいたいキーバインド入門 ref: https://qiita.com/yousan/items/9880abdc24431316fa84
shell> cd /path/to/hoge
@yousan
yousan / class-addpage.php
Created September 28, 2015 09:39 — forked from miya0001/class-addpage.php
WordPressに独自のページを表示する
<?php
if (!class_exists('WP_AddPage')):
class WP_AddPage {
private $rule = null;
private $title = null;
private $callback = null;
private $template = null;
private $filter = false;
@yousan
yousan / class-addrewriterules.php
Created September 28, 2015 09:40 — forked from miya0001/class-addrewriterules.php
WPに任意のURLを追加するためのクラス
<?php
if (!class_exists('WP_AddRewriteRules')):
class WP_AddRewriteRules{
private $rule = null;
private $query = null;
private $callback = null;
function __construct($rule, $query, $callback)
{
<?php
// 年度が始まる日
define('ANNUAL_START_DAY', '04-02');
/**
* 「年度」を取得する
*
*/
function get_annual_year(DateTime $date) {
@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
#!/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
<?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' ) );
}
// 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;
#!/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