author | date |
---|---|
Hajime Nakagami<[email protected]> |
Sep 27, 2024 |
Do you use vim?
I have been using vi clone for over 30 years.
# Copy directory recursive to remote SFTP server by scp | |
# scp use SFTP protocol | |
# need to install `parammiko` and `scp` | |
# https://pypi.org/project/paramiko/ | |
# https://pypi.org/project/scp/ | |
import paramiko | |
import scp | |
# Change these to their actual values |
# Related to https://gist.github.com/nakagami/b822ad3fcb72645f003e639060586be9 | |
# Retain the first element, delete the rest. | |
# modify attribute | |
# modify element | |
import xml.etree.ElementTree as ET | |
xml_data = '''<?xml version="1.0" encoding="utf-8"?> | |
<root> | |
<person id="1"> |
# openpyxl のサンプル | |
# Excel の 1シート目の先頭行の内容を読み取る | |
# 先頭行の値を 2行目に設定 | |
# B セルを削除 | |
# 出来上がった Excel を bytes データに変換 | |
import io | |
from openpyxl import load_workbook |
author | date |
---|---|
Hajime Nakagami<[email protected]> |
Sep 27, 2024 |
Do you use vim?
I have been using vi clone for over 30 years.
# sudo apt install imagemagick | |
# pip install matplotlib-backend-sixel matplotlib | |
import matplotlib | |
import matplotlib.pyplot as plt | |
import numpy as np | |
matplotlib.use('module://matplotlib-backend-sixel') | |
def plot(): | |
x = np.linspace(0, 1) |
# https://qiita.com/bjam_ha_nai/items/609924c91343a12d6769 | |
# sudo apt install libsixel-bin libsixel-dev | |
# pip install libsixel-python matplotlib | |
import matplotlib | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from libsixel.encoder import Encoder as SixelEncoder | |
from libsixel import SIXEL_OPTFLAG_WIDTH, SIXEL_OPTFLAG_HEIGHT | |
from tempfile import NamedTemporaryFile |
import xml.etree.ElementTree as ET | |
xml_data = '''<?xml version="1.0" encoding="utf-8"?> | |
<root> | |
<person id="1"> | |
<name>John Doe</name> | |
<age>30</age> | |
<city>Tokyo</city> | |
</person> | |
<person id="2"> |
import io | |
import zipfile | |
# Create and extract zip file example | |
# to file | |
with zipfile.ZipFile("test.zip", 'w') as z: | |
z.writestr('aaa/bbb/1.txt', b'aaa') | |
z.writestr('aaa/ccc/2.txt', b'ccc') | |
z.writestr('aaa/ccc/3.bin', b'\x00\x01\x02') |
import tkinter | |
root = tkinter.Tk() | |
root.geometry("600x400") | |
canvas = tkinter.Canvas(root, width=600, height=400, bg="white") | |
canvas.pack() | |
def event_handler(event): | |
print(event) | |
if event.type == tkinter.EventType.ButtonRelease: |
#!/usr/bin/env python | |
# Copyright (c) Twisted Matrix Laboratories. | |
# See LICENSE for details. | |
""" | |
An example of using Twisted with Tkinter. | |
Displays a frame with buttons that responds to mouse clicks. |