Skip to content

Instantly share code, notes, and snippets.

@tesths
tesths / sheet.vba
Created August 30, 2021 01:13
excel sheet 拆分
' Mac
' 右键点击 Sheet 页,选择“查看代码”
Sub 工作薄拆分()
Dim PATH As String
PATH = Application.ActiveWorkbook.PATH
Dim sht As Worksheet
Application.ScreenUpdating = False
For Each sht In Sheets
sht.Copy
'下面这句话用来拼接生成路径
'忽略等比例统一 word 尺寸
Sub FormatPics()
Dim Shap As InlineShape
For Each Shap In ActiveDocument.InlineShapes
If Shap.Type = wdInlineShapePicture Then
Shap.LockAspectRatio = msoFalse '不锁定纵横比
Shap.Width = CentimetersToPoints(10) '宽10CM
Shap.Height = CentimetersToPoints(7) '高7CM
End If
Next
@tesths
tesths / msoWord_SplitPages.vbs
Last active May 17, 2021 00:55 — forked from wangye/msoWord_SplitPages.vbs
VBScript/VBS/VBA split single word document to multi-documents by pages
'
' Description: VBScript/VBS/VBA
' split single word document
' to multi-documents by pages
' Author: wangye <pcn88 at hotmail dot com>
' Website: http://wangye.org
' Copyright by author
'
Const PrevPage = 0
Const NextPage = 1
from pdf2image.exceptions import (
PDFInfoNotInstalledError,
PDFPageCountError,
PDFSyntaxError
)
from pdf2image import convert_from_path, convert_from_bytes
images = convert_from_path('/Users/tesths/Downloads/11/3.pdf')
# Do something here
for index, img in enumerate(images):
@tesths
tesths / 拆分 word.md
Created October 15, 2020 02:46
拆分 word
  1. 打开文档。

  2. 快捷键Alt + F11打开VBA编辑器,选择菜单“插入->模块”

  3. 粘贴代码

Option Explicit

Sub SplitEveryFivePagesAsDocuments()

@tesths
tesths / heic.py
Created October 7, 2020 00:36
heic to jpg
# source https://github.com/mpapazog/heic-to-jpg
import os, subprocess
directory = '.'
for filename in os.listdir(directory):
if filename.lower().endswith(".heic"):
print('Converting %s...' % os.path.join(directory, filename))
subprocess.run(["magick", "%s" % filename, "%s" % (filename[0:-5] + '.jpg')])
continue
@tesths
tesths / file.rb
Last active July 24, 2020 14:28
ruby move folder file
require 'pathname'
files, dirs = Pathname.glob('**/*').partition(&:file?)
# puts files.class
require 'fileutils'
def archive_src_to_dst_dir(src_dir, dst_dir)
if File.exist?(dst_dir)
if File.extname(src_dir)
puts "image"
{"_id":"itjuzi","startUrl":["https://www.itjuzi.com/search?data=K12"],"selectors":[{"id":"element","type":"SelectorElementClick","parentSelectors":["_root"],"selector":".list-normal li","multiple":true,"delay":"2000","clickElementSelector":".more span","clickType":"clickMore","discardInitialElements":"do-not-discard","clickElementUniquenessType":"uniqueText"},{"id":"link","type":"SelectorLink","parentSelectors":["element"],"selector":"a","multiple":false,"delay":0},{"id":"name","type":"SelectorText","parentSelectors":["link"],"selector":"h1","multiple":false,"regex":".*?(?=(\\s))","delay":0},{"id":"status","type":"SelectorText","parentSelectors":["link"],"selector":"span.status","multiple":false,"regex":"","delay":0},{"id":"slogan","type":"SelectorText","parentSelectors":["link"],"selector":"h2.slogan","multiple":false,"regex":"","delay":0},{"id":"information","type":"SelectorText","parentSelectors":["link"],"selector":"div.summary","multiple":false,"regex":"","delay":0},{"id":"company","type":"SelectorText",
--UPDATE albumwithtext
--SET
-- "img-src" = REPLACE("img-src", 'small', 'large');
DELETE FROM albumwithtext
--SELECT * FROM albumwithtext
WHERE "text" like '%预览%'
OR "text" like '%饭绘%'
OR "text" like '%截图%'
OR "text" like '%后记%'
{
"_id": "weibo",
"startUrl": [
"https://photo.weibo.com/2426102157/talbum/index/mode/3/page/[1-420]"
],
"selectors": [
{
"id": "img",
"type": "SelectorImage",
"parentSelectors": [