Skip to content

Instantly share code, notes, and snippets.

@hideki-a
hideki-a / sort_ids.swift
Created August 4, 2016 04:19
指定した順で配列の値を並べる
var mtCategoryIds = [1,2,3,4,5,7,8,9]
var savedCategoriesOrder = [3,7,2,1,5,4,6]
var dispCategoryIds: [Int] = []
for categoryId in savedCategoriesOrder {
if let index = mtCategoryIds.indexOf(categoryId) {
dispCategoryIds.append(categoryId)
mtCategoryIds.removeAtIndex(index)
} else {
if let index = savedCategoriesOrder.indexOf(categoryId) {
@hideki-a
hideki-a / fiscal_year_monthly_list.mtml
Last active June 7, 2016 05:56
月別アーカイブへのリンクを年度毎にまとめて出力する(年度は降順・月は昇順)
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>年度毎に月別アーカイブへのリンクを出力</title>
</head>
<body>
<mt:ArchiveList type="Monthly">
<$mt:ArchiveTitle regex_replace="/(\d+)年\d+月/","$1" setvar="tmp__current_year"$>
@hideki-a
hideki-a / config.yaml
Last active April 18, 2016 22:03
ウェブページの一覧にルートからのパスを表示する。(表示オプションでフルパスを選択する。)
id: DispPageFullPath
name: DispPageFullPath
version: 1.0
list_properties:
page:
fullpath:
label: 'フルパス'
html: >
sub {
@hideki-a
hideki-a / config.yaml
Last active April 12, 2016 05:07
EntryBodyFormatプラグイン:本文のフォーマットの選択値を<$mt:EntryBodyFormat$>で取得する。
name: EntryBodyFormat
key: EntryBodyFormat
id: EntryBodyFormat
version: 1.00
tags:
function:
EntryBodyFormat: >
sub {
my ($ctx, $args) = @_;
@hideki-a
hideki-a / display_entries_with_random_on_dynamic_publishing.mtml
Created December 21, 2015 09:21
ダイナミックパブリッシングで記事をランダムに表示する。スタティックの場合はRandom Entriesプラグインが使えるかと。
<mt:Entries>
<mt:SetVarBlock name="tmp.entry_ids" function="push"><$mt:EntryID$></mt:SetVarBlock>
</mt:Entries>
<mt:Ignore>MTArrayShuffle...alfasado/mt-plugin-get-hash-varのインストールで利用可能なファンクションタグ</mt:Ignore>
<$mt:ArrayShuffle name="tmp.entry_ids"$>
<mt:Loop name="tmp.entry_ids">
<mt:If name="__first__"><ul></mt:If>
<mt:Entries id="$__value__">
@hideki-a
hideki-a / config.yaml
Created December 2, 2015 04:47
指定の範囲内で乱数を発生させるプラグイン
id: SetRandomNumVar
name: Set Random Number Variable Plugin
version: 1.0
author_name: Hideki Abe
author_link: https://www.anothersky.pw/
tags:
function:
SetRandomNumVar:
handler: >
sub {
@hideki-a
hideki-a / config.yaml
Last active December 1, 2015 06:29
記事の『出力ファイル名』(ベースネーム)でフィルタを書けて記事を出力する
name: EntriesBasenameFilter
tags:
filters:
Entries:
basename_filter:
handler: >
sub {
my ( $ctx, $args, $cond ) = @_;
$ctx->{ terms }->{ basename } = { like => $args->{ basename_filter } };
}
@hideki-a
hideki-a / .prettifyrc
Created November 26, 2015 09:09
インデントなしHTMLをインデントありHTMLに変換
{
"indent": 2,
"indent_char": " ",
"indent_scripts": "normal",
"wrap_line_length": 0,
"brace_style": "expand",
"preserve_newlines": true,
"max_preserve_newlines": 1,
"unformatted": [
"a",
@hideki-a
hideki-a / mt_blog_config_set.mtml
Created November 25, 2015 09:38
全てのブログに設定を適用するコードの例。
<mt:PerlScript>
use MT::Blog;
# ブログオブジェクトの読み込み
my @blogs = MT::Blog->load;
for my $blog (@blogs) {
# ------------------
# 設定変更
# ------------------
@hideki-a
hideki-a / mt_load_entries_with_cf.pl
Last active November 24, 2015 05:20
MTカスタムフィールドの研究
# 基礎
# /Users/Shared/Sites/mt6/htdocs/mt/lib/MT/Template/Tags/Entry.pm
# $typeの中身
# {
# 'name' => 'field.data_int_number_of_employees',
# 'pkg' => 'MT::Entry',
# 'type' => 'vinteger_idx',
# 'type_id' => '5'
# }
my $col = 'data_aircraft_type';