Skip to content

Instantly share code, notes, and snippets.

View takemikami's full-sized avatar

Mikami, Takeshi takemikami

View GitHub Profile
@takemikami
takemikami / walkman_cp.py
Last active July 25, 2017 16:46
itunes walkman playlist sync script
from xml.etree.ElementTree import *
import urllib.parse
import os
import shutil
filename = "<put your itunes library dir>/iTunes Library.xml"
walkman_music_root = '/Volumes/WALKMAN/MUSIC'
# load itunes library xml
def load_ituneslib(fname):
@takemikami
takemikami / idioms_list_dict.py
Created January 19, 2018 08:55
python idioms for list[dict]
sample = [
{'name': 'hoge', 'val1': 10},
{'name': 'fuga', 'val1': 30},
]
# filter #1
filter(lambda x: x['val1'] > 20, sample)
# => [{'val1': 30, 'name': 'fuga'}]
# filter #2
@takemikami
takemikami / google_checks_old.xml
Last active February 27, 2018 02:21
Checkstyle configuration for Gradle 4.5.1. put 'google_checks_old.xml' to 'config/checkstyle/checkstyle.xml', and run 'gradle checkstyleMain'.
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html.
Checkstyle is very configurable. Be sure to read the documentation at
@takemikami
takemikami / .gitignore
Last active August 27, 2018 07:32
.gitignore setting sample for JetBrains IntelliJ IDEA
# ignore all idea settings
.idea/*
*.iws
*.iml
*.ipr
# gradle project minimum
!.idea/gradle.xml
!.idea/misc.xml
@takemikami
takemikami / basic_sample.py
Last active April 11, 2019 07:09
pyspark.sql code samples
from pyspark.sql import functions as F
df = spark.createDataFrame([(1, 1.2345), (2, 9.8765)], ["col1", "col2"])
# 型のキャスト
df.select(F.col("col2").cast("int")).show()
# ↓
# +----+
# |col2|
# +----+
@takemikami
takemikami / parse_techbookfest_orders.py
Last active April 23, 2019 12:18
技術書典: 頒布物支払い状況 をCSVにする使い捨てスクリプト
# 技術書典: 頒布物支払い状況 をCSVにする使い捨てスクリプト
# わたしの場合はこれでCSV変換できましたが、
# どんなパターンがあるか分からないので、変換できるかは分からないです
#
# 1. 頒布物支払い状況をChromeで開く
# 2. ファイル→ページを別名で保存
# 3. 保存したhtmlをorder.htmlに名称変更
# 4. pip install beautifulsoup4
# 5. pip install html5lib
# 6. このファイルをorder.htmlと同じディレクトリに置く
@takemikami
takemikami / imasparql2atok.py
Last active September 3, 2019 18:05
im@sparqlからアイドルの姓名を取り出し、ATOKに単語登録するためのスクリプト
# im@sparql to atok dic
# im@sparqlからアイドルの姓名を取り出し、ATOKに単語登録するためのスクリプト
#
# 登録手順:
# 1. pip install SPARQLWrapper
# 2. python imasparql2atok.py | sort | uniq | nkf -w16 -Lw > imasparql-dic.txt
# 3. atok -> 辞書ユーティリティー
# 4. ツール -> ファイルから登録削除
# 5. 単語ファイルに、imasparql-dic.txtを選択して、登録ボタンを押す
@takemikami
takemikami / sample_575
Last active September 7, 2019 05:22
im@sparqlのサンプルクエリ
PREFIX schema: <http://schema.org/>
PREFIX imas: <https://sparql.crssnky.xyz/imasrdf/URIs/imas-schema.ttl#>
SELECT (concat(group_concat(?nm1; separator=''), ' ', group_concat(?nm2; separator=''), ' ', group_concat(?nm3; separator='')) as ?h)
WHERE {
{ SELECT (1 as ?g) (?nm as ?nm1) ("" as ?nm2) ("" as ?nm3)
WHERE { ?s imas:nameKana ?nm. FILTER (strlen(str(?nm)) = 5) }
ORDER BY RAND() LIMIT 1
} UNION { SELECT (1 as ?g) ("" as ?nm1) (?nm as ?nm2) ("" as ?nm3)
WHERE { ?s imas:nameKana ?nm. FILTER (strlen(str(?nm)) = 7) }
ORDER BY RAND() LIMIT 1
@takemikami
takemikami / imasparql2gboard.py
Last active April 5, 2020 09:33
im@sparqlからアイドルの姓名を取り出し、GBoardに単語登録するためのスクリプト
# im@sparql to gboard dic
# im@sparqlからアイドルの姓名を取り出し、GBoardに単語登録するためのスクリプト
#
# 登録手順:
# 1. pip install SPARQLWrapper
# 2. python imasparql2gboard.py | sort | uniq > dictionary.txt
# 3. zip PersonalDictionary.zip dictionary.txt
# 3. Android端末に転送(GoogleDriveとか、OneDriveとかを使えば良い)
# 4. 以降はAndroid端末で操作
# 4.1. 設定→システム→言語と入力→仮想キーボード→GBoard→単語リスト→日本語→メニューからインポート
@takemikami
takemikami / IdolSearch.vue
Created July 25, 2020 19:26
im@sparqlの情報を使って、アイドルのインクリメンタルサーチ
<template>
<div class="hello">
<input type="text" v-model="searchText"></input>
<ul>
<li v-for="item in candidates">{{ item.text }}</li>
</ul>
</div>
</template>
<script>