Skip to content

Instantly share code, notes, and snippets.

View cm3's full-sized avatar

KAMEDA Akihiro cm3

  • National Museum of Japanese History
  • Chiba, Japan
  • X @cm3
View GitHub Profile
@cm3
cm3 / bookmarklet.txt
Created January 10, 2024 04:17
Get Current Folder Path in Google Drive
javascript:(function(){var elementsX=document.querySelectorAll('nav[guidedhelpid="folder_path"] [data-tooltip]');var tooltipsX=Array.from(elementsX).map(function(el){return el.getAttribute('data-tooltip');});var elementsY=document.querySelectorAll('div[data-target="collapsedFolderDropdown"] [data-tooltip]');var tooltipsY=Array.from(elementsY).map(function(el){return el.getAttribute('data-tooltip');});var combinedTooltips=[tooltipsX.shift(),...tooltipsY,...tooltipsX].join(' > ');navigator.clipboard.writeText(combinedTooltips).then(function(){alert('Copied to clipboard: '+combinedTooltips);}).catch(function(err){console.error('Error copying to clipboard: ',err);});})();
@cm3
cm3 / Q79934.ttl
Last active March 24, 2022 10:18
sample of normalized quantity in Wikidata
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix wd: <http://www.wikidata.org/entity/> .
@prefix wdt: <http://www.wikidata.org/prop/direct/> .
@prefix wikibase: <http://wikiba.se/ontology#> .
@prefix wds: <http://www.wikidata.org/entity/statement/> .
@prefix wdv: <http://www.wikidata.org/value/> .
@prefix p: <http://www.wikidata.org/prop/> .
@prefix psv: </prop/statement/value/> .
@prefix psn: </prop/statement/value-normalized/> .
@cm3
cm3 / repo.ttl
Last active March 22, 2022 16:16
Depicting relationships among "repositories" in Wikidata
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix wd: <http://www.wikidata.org/entity/> .
@prefix wdt: <http://www.wikidata.org/prop/direct/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
wdt:P1535 rdfs:label "used by"@en.
wdt:P279 rdfs:label "subclass of"@en.
wdt:P1014 rdfs:label "Art & Architecture Thesaurus ID"@en.
wdt:P1889 rdfs:label "different from"@en.
wdt:P2888 rdfs:label "exact match"@en.
@cm3
cm3 / convert.py
Last active February 13, 2022 15:23
stroly-json from https://stroly.com/ to GeoJSON
import json
with open("landmark1 (1).json", "r", encoding="utf8") as fr:
landmarks = json.load(fr)["landmarks"]
with open("landmark.geojson", "w", encoding="utf8") as fw:
fw.write("""{
"type": "FeatureCollection",
"name": "points",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
@cm3
cm3 / tageta.ttl
Created June 2, 2021 06:18
Sample documentation of an ethnographical object using CIDOC CRM and Object Biography Ontology
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix crm: <http://www.cidoc-crm.org/cidoc-crm/> .
@prefix rekimin_e: <https://khirin-c.rekihaku.ac.jp/rdf/nmjh_rekimin_e/> .
@prefix rekimin_e_31749180: <https://khirin-c.rekihaku.ac.jp/rdf/nmjh_rekimin_e/31749180#> .
@prefix rekimin_e_entities: <https://khirin-c.rekihaku.ac.jp/rdf/nmjh_rekimin_e_entities/> .
@prefix khirin_agent: <https://khirin-c.rekihaku.ac.jp/rdf/agent/> .
@prefix khirin_datetime: <https://khirin-c.rekihaku.ac.jp/rdf/datetime/> .
@prefix khirin_geo: <https://khirin-c.rekihaku.ac.jp/rdf/geo/> .
@prefix khirin_type: <http://khirin-c.rekihaku.ac.jp/rdf/type/> .
@prefix ob: <http://purl.org/object-biography/#> .
@cm3
cm3 / fnv1a32.js
Last active April 14, 2021 15:00
fnv1a_32 in JavaScript. see the history for a without-BigInt version
const fnva = function(data){
hval = BigInt(0x811c9dc5)
for (var i = 0; i < data.length; i++){
hval ^= BigInt(data[i])
hval = (hval * BigInt(0x01000193)) % BigInt(2**32)
}
return hval.toString(16).slice(-8).toUpperCase()
}
const encoder = new TextEncoder()
@cm3
cm3 / index.html
Last active January 4, 2020 04:56
google photos album viewer sample (each description is supposed to begin with month/day), IDs and keys should be replaced. See http://cm3.hateblo.jp/entry/2020/01/04/034303
<html>
<head>
<script src="https://apis.google.com/js/api.js"></script>
<script src="https://unpkg.com/vue"></script>
<script>
const getDatedList = function (_original){
const datePattern = /^(\d+)\/(\d+)\s+/;
arranged_list = [...Array(367)].map(e => {return {}}); //other and 365+(1 for leap year)
for (let i=0; i<_original.length; i++){
@cm3
cm3 / gen_shrine_list.py
Created December 22, 2019 07:24
print geojson of shrines in the historical map data provided by nihu https://www.nihu.jp/ja/publication/source_map
import csv
template_body = """
{{
"type": "FeatureCollection",
"features": [{items}]
}}
"""
template_item = """
#!/usr/bin/env python3
import os
import time
import sys
from datetime import datetime
from win10toast import ToastNotifier
import pyscreenshot
from PIL import Image

J-GLOBAL KNOWLEDGE で使われている property 一覧

J-GLOBAL knowledge のプロパティを列挙。一般には 31件ヒット。

Sparql

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dcterms: <http://purl.org/dc/terms/>
select ?p
where