Skip to content

Instantly share code, notes, and snippets.

View cognitom's full-sized avatar

Tsutomu Kawamura cognitom

View GitHub Profile
@cognitom
cognitom / app.tag
Last active July 3, 2016 05:54
How to use postcss with Riot.js
<app>
<h1>Riot</h1>
<p>A React-like user interface micro-library.</p>
<style scoped type="external">
:scope {
display: block;
}
h1 {
border-bottom: 1px solid black;
@cognitom
cognitom / download.js
Last active January 7, 2023 07:34
openBDの全データを整形しつつ単一ファイルにダウンロード
import {join} from 'path'
import {createWriteStream} from 'fs'
import request from 'request'
import {parse, stringify} from 'JSONStream'
import find from 'lodash.get'
import highland from 'highland'
const apiRoot = 'https://api.openbd.jp/v1'
const cwd = process.cwd()
const distFile = join(cwd, 'all.json')
@cognitom
cognitom / normalizeDate.js
Created January 30, 2017 02:13
openBDの日付フィールドのノーマライズ
function normalizeDate (raw) {
const patterns = [
// 2017-01-30
{re: /^\d{4}-\d{2}-\d{2}($|,)/, f: m => m[0]},
// 2017-01
{re: /^\d{4}-\d{2}($|,)/, f: m => m[0]},
// 2017
{re: /^\d{4}($|,)/, f: m => m[0]},
// 20170130
{re: /^(\d{4})(\d{2})(\d{2})($|,)/, f: m => `${m[1]}-${m[2]}-${m[3]}`},
@cognitom
cognitom / quickstart.js
Last active June 4, 2024 04:16
Unspaghetti version of Google Spreadsheet API example code
import {readFile, writeFile, mkdir} from 'mz/fs'
import readline from 'mz/readline'
import promisify from 'es6-promisify'
import google from 'googleapis'
import googleAuth from 'google-auth-library'
import clientSecret from './client_secret.json'
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/sheets.googleapis.com-nodejs-quickstart.json
const SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
@cognitom
cognitom / jisx6004 romantable.txt
Created January 17, 2019 14:08 — forked from ytomino/romantable_jisx6004.txt
JIS-X-6004 for Google日本語入力
- -
~ 〜
〜~ ~
. 。
, 、
[ ち
] 」
{ 「
} 」
・. …
@cognitom
cognitom / group-name.sh
Created September 18, 2021 01:56
In some cases, I got to get the user/group's name from its id. Here's how-to.
# provide some group's id
$gid=1000
# POSIX way
cat /etc/group | grep ":x:$gid:" | cut -d: -f1
# non-POSIX way which also handles LDAP
getent group "$gid" | cut -d: -f1
# Note that we can't use `id` command for this purpose.
@cognitom
cognitom / keymap.c
Last active January 11, 2023 02:36
Lock key indicator with RGB matrix on QMK
// keymap setting and etc...
// store the state
static bool _is_key_locked = false;
void keyboard_post_init_user(void) {
// need to stop effects and animations
rgb_matrix_mode(RGB_MATRIX_NONE);
rgb_matrix_sethsv(HSV_OFF);
}