Skip to content

Instantly share code, notes, and snippets.

View ko31's full-sized avatar
I want to play catch!

Ko Takagi ko31

I want to play catch!
View GitHub Profile
@ko31
ko31 / result.json
Last active December 11, 2016 13:19
【JavaScript】将棋連盟棋士データベースより棋士情報をスクレイピングしたjson
{
"birthday": "1970年9月27日(46歳)",
"birthplace": "埼玉県所沢市",
"image": "http://www.shogi.or.jp/images/player/pro/175.jpg",
"junni": "A級(A級以上:24期)",
"name": "羽生善治",
"no": "175",
"ryuou": "1組(1組以上:26期)"
}
@ko31
ko31 / scraper.php
Created December 13, 2016 16:35
【PHP】将棋連盟棋士データベースより棋士情報をスクレイピングするクラス
<?php
require_once 'vendor/autoload.php';
use Goutte\Client;
class Scraper {
protected $client;
public function __construct() {
$this->client = new Client();
@ko31
ko31 / get_json.php
Created December 13, 2016 16:36
【PHP】全棋士データからjsonファイル作成
<?php
require_once 'scraper.php';
$scraper = new Scraper();
$data = array();
for ($i=1; $i<=308; $i++) {
$_kishi = $scraper->getKishi($i);
if ($_kishi) {
<?php
$prefecture = array(
array('北海道', 0),
array('青森県', 0),
array('岩手県', 0),
array('宮城県', 0),
array('秋田県', 0),
array('山形県', 0),
array('福島県', 0),
array('茨城県', 0),
@ko31
ko31 / get_pos_data.php
Created December 16, 2016 00:25
【PHP】出身地から緯度・経度を取得したデータを作る
<?php
$key = 'xxxxxxxxxx';
$data = file_get_contents("kishi_all.json");
$data = json_decode($data);
$maps = array();
foreach($data as $kishi) {
$result = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($kishi->birthplace).'&key='.$key);
$result = json_decode($result, true);
if ($result['status'] != 'OK') {
continue;
@ko31
ko31 / index.html
Created December 16, 2016 02:31
【HTML】棋士出身地マップ
<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
<link rel="stylesheet" href="css/leaflet.css" />
<script src="js/leaflet.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
@ko31
ko31 / example.html
Created December 18, 2016 21:25
jQuery quicksearch plug-in example
<form>
<input type="text" id="search" placeholder="検索キーワードを入れてください">
</form>
<table class="list" id="tabledata">
<tbody>
<tr>
<th>棋士番号</th>
<th>氏名</th>
<th>出身地</th>
@ko31
ko31 / get_list_data.php
Created December 20, 2016 12:24
【PHP】棋士名を分解してどの文字が何回使われているか取得
<?php
$data = file_get_contents("kishi_all.json");
$data = json_decode($data);
$list = array();
foreach ($data as $kishi) {
$length = mb_strlen($kishi->name, 'UTF-8');
for($i=0; $i<$length; $i++) {
$char = mb_substr($kishi->name, $i, 1, 'UTF-8');
if (isset($list[$char])) {
@ko31
ko31 / test.php
Last active December 26, 2016 07:57
【PHP】Cloud Vision APIのテスト
<?php
// APIキー
$api_key = "Your API Key";
// 画像パス
$image_path = "/path/to/image.jpg";
// リクエスト用のJSONを作成
$json = json_encode( array(
"requests" => array(
@ko31
ko31 / wp-cli-verify-checksums
Created February 15, 2017 12:37
サーバー内にあるWordPress本体の改ざんをチェックする
find . -type f -name 'wp-load.php' -exec bash -c '_wp=$(echo {} | sed -e s/[^\/]*$//); echo -n "${_wp}: "; wp --path=${_wp} core verify-checksums || echo "WP not installed."' \; 2>/dev/null