Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nakagami's full-sized avatar

Hajime Nakagami nakagami

View GitHub Profile
package main
import (
"database/sql"
"fmt"
"log"
"github.com/jmoiron/sqlx"
_ "github.com/nakagami/firebirdsql"
)
@nakagami
nakagami / pg_scram_sha_256.py
Created September 24, 2018 22:01
PostgreSQL SCRAM-SHA-256 authentication
import hashlib
import hmac
import base64
import binascii
password = 'foobar'
client_nonce = '9IZ2O01zb9IgiIZ1WJ/zgpJB'
server = {
'r': '9IZ2O01zb9IgiIZ1WJ/zgpJBjx/oIRLs02gGSHcw1KEty3eY',
's': 'fs3IXBy7U7+IvVjZ',
@nakagami
nakagami / mssql_python.rst
Created August 4, 2018 00:24
Python and MS SQL Server, MS SQL Server and Python

MySQL 8.0 の認証 plugin について

MySQL は、mysql.user テーブルにユーザー情報を持っていて、その中に、パスワードを なんらかの手順で ハッシュ化した値を保存している。

何らかの手順 は、プラグイン方式なっていて「認証プラグイン名」として認識されている。

  • mysql_native_password → MySQL 5.7 までのデフォルトの認証プラグイン
  • caching_sha2_password → MySQL 8.0 のデフォルトの認証プラグイン
@nakagami
nakagami / jabstract.py
Last active April 4, 2021 05:31
Japanese summarization module using LexRank algorithm.
#!/usr/bin/env python
# The MIT License (MIT)
# Copyright © 2015 Recruit Technologies Co.,Ltd.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@nakagami
nakagami / word2vec_sample.rst
Last active April 9, 2018 05:00
python + word2vec 最初のサンプルコード

word2vec を使って類似語を探す

白ヤギコーポレーションさんが作成、公開している日本語モデルを使ってみます

http://aial.shiroyagi.co.jp/2017/02/japanese-word2vec-model-builder/

$ curl http://public.shiroyagi.s3.amazonaws.com/latest-ja-word2vec-gensim-model.zip > latest-ja-word2vec-gensim-model.zip
@nakagami
nakagami / wagahaiwa_nekodearu_yomi.py
Last active March 30, 2018 07:10
青空文庫の「我輩は猫である」を形態素解析して読み仮名を表示
import io
import re
import collections
import zipfile
import requests
from janome.tokenizer import Tokenizer
r = requests.get('http://www.aozora.gr.jp/cards/000148/files/789_ruby_5639.zip')
f = zipfile.ZipFile(io.BytesIO(r.content)).open('wagahaiwa_nekodearu.txt')
@nakagami
nakagami / jawikipedia_count.py
Last active April 6, 2018 00:31
ウィキペディア日本語版で多く参照されているページ
"""ウィキペディア日本語版のアーカイブファイルから多く参照されているページをリスト
https://dumps.wikimedia.org/jawiki/latest/ に最新のアーカイブファイルが存在する
以下のコマンドで記事が1ファイルになった jawiki-latest-pages-articles.xml をカレントディレクトリにおいてからスクリプトを実行
::
curl https://dumps.wikimedia.org/jawiki/latest/jawiki-latest-pages-articles.xml.bz2 |bzcat > jawiki-latest-pages-articles.xml
"""
import collections
import re
@nakagami
nakagami / wagahaiwa_nekodearu.py
Last active March 29, 2018 08:43
青空文庫の「我輩は猫である」を形態素解析して4文字以上の名詞の出現頻度の高い順にベスト30を表示
import io
import re
import collections
import zipfile
import requests
from janome.tokenizer import Tokenizer
r = requests.get('http://www.aozora.gr.jp/cards/000148/files/789_ruby_5639.zip')
f = zipfile.ZipFile(io.BytesIO(r.content)).open('wagahaiwa_nekodearu.txt')