Skip to content

Instantly share code, notes, and snippets.

@hitsujixgit
hitsujixgit / yokohama_codes_and_stat.csv
Created July 22, 2014 11:49
横浜市行政区毎の0-5歳人口, 市全年齢の人口
cityid name demographics-0 demographics-1 demographics-2 demographics-3 demographics-4 demographics-5 ttl
id141011 鶴見区 2712 2875 2812 2589 2518 2525 280234
id141020 神奈川区 2037 1960 1971 1916 1736 1812 234496
id141038 西区 869 854 809 746 733 692 97251
id141046 中区 1112 1150 1052 1081 942 975 147065
id141054 南区 1351 1419 1356 1385 1369 1409 194393
id141119 港南区 1551 1660 1682 1715 1779 1730 217782
id141062 保土ヶ谷区 1432 1469 1485 1542 1444 1492 204290
id141127 旭区 1853 1912 1934 2016 2039 1981 248560
id141071 磯子区 1261 1360 1280 1257 1314 1363 161968
id141089 金沢区 1362 1481 1547 1583 1569 1670 204453
id141097 港北区 3455 3294 3122 2885 2758 2721 338969
id141135 緑区 1519 1602 1602 1670 1652 1563 178783
id141178 青葉区 2614 2780 2644 2777 2766 2812 307844
id141186 都筑区 2120 2235 2441 2341 2451 2279 209626
id141101 戸塚区 2384 2494 2472 2517 2474 2559 273962
id141151 栄区 972 986 1014 972 1004 1018 123176
id141160 泉区 1204 1295 1255 1318 1313 1350 154807
id141143 瀬谷区 1006 1028 1046 1013 1069 1125 125599
@hitsujixgit
hitsujixgit / conv_json_to_csv.py
Created July 20, 2014 05:52
Read a json file written with specific format, convert the data to 2nd dim list and write it as a csv file.
#coding:utf-8
'''
Created on 2014/7/20
@author: Tae Matsumoto
JSONファイルを読み込み、同名のCSVファイルを出力します。
読み込む対象のJSONファイルの構造は下記の通り。
[{'key':区名1, 'stat':{0:0歳人口,1:1歳人口,...}},{'key':区名2, 'stat':{0:0歳人口,1:1歳人口,...}},...]
'''
@hitsujixgit
hitsujixgit / content-excerpt.php
Created July 15, 2014 04:51
Show the excerpt of the post in WP.
<article class="post post-excerpt">
<header class="post-header">
<?php
$link = get_permalink($post->ID);
?>
<h3 class="post-title"><a href="<?php echo $link; ?>"><?php the_title(); ?></a></h3>
<p class="post-meta">
<time class="post-date" pubdate><?php echo get_the_date(); ?></time>
</p>
</header>
@hitsujixgit
hitsujixgit / index.html
Created July 14, 2014 12:54
Add y-axis to bar graph using d3.js.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v0.min.js"></script>
<style type="text/css">
body {
font-family: 'Lucida Grande','Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
}
@hitsujixgit
hitsujixgit / index.html
Created July 11, 2014 01:26
Including a JSON file, it show bar graph.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v0.min.js"></script>
<style type="text/css">
body {
font-family: 'Lucida Grande','Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
}
@hitsujixgit
hitsujixgit / include-post.php
Created July 9, 2014 02:06
ショートコードでslugを指定して、投稿記事を表示するプラグイン
<?php
/*
Plugin Name: Include post
Plugin URI: http://wordpress.hitsuji.me
Description: ショートコードでslugを指定して、投稿記事を表示するプラグインです
Version: 1.0
Author: Hitsuji
Author URI: http://hitsuji.me/about-me/
*/
@hitsujixgit
hitsujixgit / read_yokohama_stat.pl
Created July 9, 2014 01:40
横浜市統計ポータルサイトの年齢別人口データのうち、総人口と0〜5歳各年齢の人口を入手してJSONファイルに書き出します。
#! /opt/local/bin/perl
use strict;
use warnings;
use 5.012;
use Encode;
use HTML::TableExtract;
use utf8;
use LWP::Simple;
use JSON qw( decode_json encode_json );
@hitsujixgit
hitsujixgit / frontpage4categories.php
Created July 8, 2014 04:19
Wordpress page template showing 4 categories links with each title, thumbnail and description.
<?php
/*
Template Name: Front page with 4 categories
*/
get_header(); ?>
<!-- メイン -->
<div id="content">
<img id="frontpage-image" src="<?php echo get_template_directory_uri() ?>/img/sky_2x.jpg" width="900" height="200" />
<div id="main">
<?php
@hitsujixgit
hitsujixgit / read_yokohama_population.pl
Created July 7, 2014 01:13
Read stat of Yokohama city web.
#! /opt/local/bin/perl
use strict;
use warnings;
use 5.012;
use Encode;
use HTML::TableExtract;
use utf8;
my $filepath = "test.html";
open(FILE, $filepath) or die "Open a html file failed.";
@hitsujixgit
hitsujixgit / category-information-acquisition.php
Created June 28, 2014 10:56
特定のテンプレートに記事を挿入する - 実践的テーマを作成する #6 コードの一部のみ
if(have_posts()) {
echo '<h2 class="post-title">'.$title.'</h2>';
// 固定ページ "category-information-acquisition" の本文を挿入する
$cat_discription_page = get_page_by_path('category-information-acquisition');
if(isset($cat_discription_page)) {
echo '<div class="post-content">'.apply_filters('the_content', $cat_discription_page->post_content).'</div><hr />';
}
while(have_posts()) {
the_post();
get_template_part('content','excerpt');