This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Extract a file in a zip file, without opening the zip file | |
Parameters------- | |
file_to_get: | |
filename like 'test.txt' to get | |
zip_file: | |
target zip filename like 'zipfile.zip' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Backup .py, .ipynb files to other dierctory (ex. USB device) | |
Parameters | |
--- | |
dir_to_root: str | |
Directory path backup to, like '/media/user/USB_DISK/backup_here' | |
dir_from: str | |
All .py, .ipynb files in this directory are back-up(recursively). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
start_time = time.time() | |
# write some code that you want to know time | |
elapsed_time = time.time() - start_time | |
print("elapsed time: {}".format(elapsed_time) + "[sec]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Manually see and evaluate Yes or No for each item in a list_test. | |
Checked results are devided to list_yes of list_no. | |
''' | |
# in ipython, to clear_output console | |
# from IPython.display import clear_output | |
def query_yes_no(question, default="yes"): | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sqlite3 | |
from flask import Blueprint, Flask, current_app, g, render_template, request | |
# manually set instance dir | |
app = Flask(__name__, instance_path='/home/../simple/instance') | |
app.config.from_mapping( | |
DATABASE=os.path.join(app.instance_path, 'simple.sqlite') | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<script> | |
/*copy form id1 to id2*/ | |
function copyForm(id1,id2){ | |
var a=document.getElementById(id1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
</head> | |
<body> | |
<script> | |
function add() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import time | |
set_time = datetime.datetime(2019, 12, 31, 19, 0) | |
now_time = datetime.datetime.now() | |
delta = set_time - now_time | |
sec_in_day = (delta.total_seconds() - delta.days*24*60*60) | |
hours = int(sec_in_day // (60*60)) | |
minutes = int((sec_in_day - hours*(60*60)) // 60) | |
seconds = int(sec_in_day - minutes*60 - hours*60*60) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
"""Resize image simply with PIL | |
Usage: | |
$ python resize_image.py filename [mode] | |
Output: | |
"resize_ + filename" is created. | |
Parameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from io import StringIO | |
from pdfminer.converter import TextConverter | |
from pdfminer.layout import LAParams | |
from pdfminer.pdfinterp import PDFPageInterpreter, PDFResourceManager | |
from pdfminer.pdfpage import PDFPage | |
space = re.compile(r"[ ]+") |
OlderNewer