Skip to content

Instantly share code, notes, and snippets.

@sidkang
sidkang / resize-pdf.py
Last active Nov 16, 2021
Resize PDF Files to Same Page Size Using Python
View resize-pdf.py
from PyPDF2 import PdfFileReader, PdfFileWriter
from PyPDF2.pdf import PageObject
from pathlib import Path
pdf_file = Path.home() / 'Downloads' / 'General harmony - practical, analysis and principle.pdf'
pdf_reader = PdfFileReader(str(pdf_file))
writer = PdfFileWriter()
# assume page 0 is the desired size
page0 = pdf_reader.getPage(0)
@sidkang
sidkang / script.scpt
Last active Nov 1, 2021
change IME using AppleScript
View script.scpt
launch application "System Events"
delay 0.1
ignoring application responses
tell application "System Events" to tell process "TextInputMenuAgent"
click menu bar item 1 of menu bar 2
end tell
end ignoring
do shell script "killall 'System Events'"
delay 0.1
View learn_pandas.py
import pandas as pd
for i in range(10):