Skip to content

Instantly share code, notes, and snippets.

@ideodora
ideodora / package.json
Created October 2, 2014 01:10
Browserify and Shim integration for window Base JS library via package.json
{
//...
// Alias local file path for browserify
// so that they can be callable by shorter name in browserify
//
"browser": {
// alias name: 'local path (related to where package.json is?)'
//
@ideodora
ideodora / gist:6e3fada11529958c55e2
Last active August 29, 2015 14:07
WP アイキャッチ
<?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
} ?>
<!-- or -->
<?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
$thumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'post-index') );
} else {
@ideodora
ideodora / gist:d8b5c9dbd6907a1c09ec
Created October 7, 2014 02:44
WP thumbnail サムネイル
add_theme_support( 'post-thumbnails' );
add_image_size('post-index', 300, 9999);
@ideodora
ideodora / gist:ca2c5c55ed8d2fe028f0
Created October 7, 2014 07:23
WP WP_Query内でのページング
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages
) );
?>
@ideodora
ideodora / gist:49d3ea790914741d1d22
Created October 7, 2014 08:09
WP 投稿時間と現在の時間比較 UnixTimestamp
$post_time = get_the_time('U');
$today = time();
@ideodora
ideodora / gist:69adfd8e36ecc3079b56
Created October 7, 2014 08:34
WP メインループ内でのページング
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
@ideodora
ideodora / gist:df7b8421d54caad29db3
Created October 9, 2014 05:04
Git 一括rm git status を利用
#git version 1.7.10.1
git status | grep -e deleted | sed -e "s/# deleted: //g" | xargs git rm
$telnet yahoo.co.jp 80
>GET / HTTP/1.0
>User-Agent: Telnet [ja] (Linux)
>Host: www.yahoo.co.jp
>
>
@ideodora
ideodora / gist:3c01cc4faf0709c0c4dc
Created October 10, 2014 11:15
datetime.date 型
import datetime
today = datetime.date.today() # 今日の日付けのdate型を作成
# 任意の数値を変えたdateを返す
Year2013SameDay = today.replace(year=2013)
Month12SameDay = today.replace(month=12)
firstDay = today.replace(day=1)
# 0001年01月01日からの経過日数
from datetime import date
from calendar import monthrange
def get_last_date(year, month):
# monthrange は月の1日の曜日と日数を返してくれる
# 日数を date に渡せば月末の日付のできあがり
youbi, day = monthrange(year, month)
last = date(year, month, day)
return last