Skip to content

Instantly share code, notes, and snippets.

/**********
* foo.php *
***********/
<?php
// Connection
$username = 'my_username';
$password = 'my_password';
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
@yeiichi
yeiichi / normalize_file_nfkc.py
Last active April 14, 2025 07:05
Normalizes the textual content of plain text or CSV files into NFKC format.
#!/usr/bin/env python3
"""Normalizes the textual content of text or CSV files into NFKC format."""
import argparse
import csv
import subprocess
from pathlib import Path
from unicodedata import normalize
# Constants
@yeiichi
yeiichi / cal_jp2gc.py
Last active October 20, 2020 05:57
cal_jp2gc.py
from unicodedata import normalize
from datetime import datetime
import re
def cal_conv_jg(jp_cal: str) -> datetime:
"""Convert Japanese Cal to Gregorian Cal"""
cal_in = jp_cal
cal_in = normalize('NFKC', cal_in)
cal_in = re.split(r'[\-.,/]', cal_in) # List: gy, m, d
from datetime import datetime
T_BEG = datetime.strptime('1912-07-30', '%Y-%m-%d') # Taisho
T_END = datetime.strptime('1926-12-25', '%Y-%m-%d')
S_BEG = datetime.strptime('1926-12-25', '%Y-%m-%d') # Showa
S_END = datetime.strptime('1989-01-07', '%Y-%m-%d')
H_BEG = datetime.strptime('1989-01-08', '%Y-%m-%d') # Heisei
H_END = datetime.strptime('2019-04-30', '%Y-%m-%d')
R_BEG = datetime.strptime('2019-05-01', '%Y-%m-%d') # Reiwa
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
import os
from urllib.parse import urljoin
from pathlib import Path
from pprint import pprint
import time
@yeiichi
yeiichi / excel_concat.py
Created November 3, 2020 00:54
Concatenates Exel files into a DataFrame
#!/usr/bin/env python
# coding: utf-8
import pandas as pd
from pathlib import Path
def excel_cat(my_dir):
"""Concatenates Exel files into a DataFrame"""
# Make a list of Excel files in the file path
@yeiichi
yeiichi / mamp_sql.sh
Created November 3, 2020 11:02
MAMP's MySQL
/Applications/MAMP/Library/bin/mysql -uUsername -pPassword
@yeiichi
yeiichi / dtsep.sh
Created November 6, 2020 18:21
my to_date
%s/\(\d\d\d\)\(\d\d\)\(\d\d\) \(\d\d\)\(\d\d\) \(\d\d\)\(\d\d\)/2020-\4-\5T\6:\7:00,\1,\2,\3/g
@yeiichi
yeiichi / plu-idn.sql
Created November 8, 2020 05:54
Inserts some records to MySQL
INSERT INTO state_code
(iso_3166_2, code_eoj, subdiv_cat, subdiv_name_en, subdiv_name_ja, geo_area)
VALUES
('ID-JW','JW','geographical unit','Jawa','ジャワ','ID-JW'),
('ID-SM','SM','geographical unit','Sumatera','スマトラ','ID-SM'),
('ID-BT','BT','province','Banten','バンテン州','ID-JW'),
('ID-JB','JB','province','Jawa Barat','西ジャワ州','ID-JW'),
('ID-JI','JI','province','Jawa Timur','東ジャワ州','ID-JW'),
('ID-JK','JK','capital district','Jakarta Raya','ジャカルタ首都特別州','ID-JW'),
('ID-JT','JT','province','Jawa Tengah','中部ジャワ州','ID-JW'),