Skip to content

Instantly share code, notes, and snippets.

@kkAyataka
kkAyataka / get_images_from_xlsx.py
Created April 7, 2023 21:46
Get images from a xlsx file.
import os
import zipfile
import xml.etree.ElementTree as xml
'''
book.xlsx/
|- _rels/
|- xl/
| |- drawings/
| | | |- _rels/
@kkAyataka
kkAyataka / js-console-group.html
Created August 1, 2021 00:50
JavaScript console.group behavior
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<!--
ボタンを連続3回クリックしたときのログ
counter: 0, 2000
@kkAyataka
kkAyataka / openssl-encrypt.cpp
Last active March 8, 2020 12:08
OpenSSL Encryption
#include <iostream>
#include <vector>
#include <openssl/evp.h>
#include <openssl/ossl_typ.h>
// OpenSSL v1.1.1d
// https://www.openssl.org/docs/man1.1.1/man7/crypto.html
// https://www.openssl.org/docs/man1.1.1/man3/EVP_CIPHER_CTX_new.html
bool Encrypt(const unsigned char * key,
@kkAyataka
kkAyataka / read_file_all.cpp
Last active October 12, 2015 05:06
Read file.
#include <fstream>
int main () {
std::ifstream fs("/file");
const std::string data((std::istreambuf_iterator<char>(fs)), std::istreambuf_iterator<char>());
}
@kkAyataka
kkAyataka / http_server.js
Created March 8, 2015 04:39
Node.js HTTP simple server.
/**
* Simple HTTP Server
*
* $ node server.js # current folder is www root
* $ node server.js www # www is www root
*
*/
var http = require('http');
var fs = require('fs');
@kkAyataka
kkAyataka / arg.py
Last active August 29, 2015 14:12
Python ArgumentParser for command line arguments
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
# とりあえずdescriptionを指定してあれば良い感じ。
# https://docs.python.org/2.7/library/argparse.html#argparse.ArgumentParser
p = argparse.ArgumentParser(description='command line sample')
# 簡単なオプション類
@kkAyataka
kkAyataka / opt.py
Last active August 29, 2015 14:11
Python OptionParser for command line arguments
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''optparseを用いているが、これはPython 2.7でdeprecated
optparseではなく、argparseを使う
'''
from optparse import OptionParser
# optionの定義
p = OptionParser()
@kkAyataka
kkAyataka / load_json_f.py
Last active August 29, 2015 14:09
Python load json file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""jsonファイル読み込み"""
import json
# ファイルから読み込み
# jsのobjectはpythonのdictとして読み込まれる
# https://docs.python.org/2.7/library/json.html?highlight=json#json-to-py-table
@kkAyataka
kkAyataka / datetime_to_string_to.py
Last active June 14, 2022 16:13
Python datetime to iso format string and iso format string to datetime
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""datetimeとISO 8601文字列の変換"""
import datetime
# datetimeからISO 8601を得る
d = datetime.datetime(2014, 11, 11, 9)
print d.isoformat() # 2014-11-11T09:00:00