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/env python3 | |
from contextlib import contextmanager | |
from fnmatch import fnmatch | |
from glob import glob | |
import subprocess as subp | |
import datetime as dt | |
import logging | |
import tarfile | |
import json | |
import sys |
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/env python3 | |
import subprocess | |
import plistlib | |
import os | |
def execute_and_grab_output(args): | |
proc = subprocess.Popen(args, stdout=subprocess.PIPE) | |
return proc.stdout.read() |
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/env python3 | |
import subprocess as subp | |
import sys | |
import os | |
exclude_list = [ | |
'System Volume Information', | |
'$RECYCLE.BIN', | |
] |
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
#!/bin/bash | |
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?) | |
if [ "$agent_run_state" = 2 ]; then | |
rm -rf /tmp/ssh-* | |
eval $(ssh-agent -s) | |
winpty setx SSH_AUTH_SOCK $SSH_AUTH_SOCK | |
winpty setx SSH_AGENT_PID $SSH_AGENT_PID | |
fi |
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 win32com.client | |
msoTrue, msoFalse = -1, 0 | |
def word2pdf(src, dst): | |
wdExportFormatPDF = 17 | |
app = win32com.client.DispatchEx('Word.Application') | |
doc = app.Documents.Open(src) |
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
'''My Simple PDF Parser | |
Can inspect the size of a PDF file. | |
''' | |
from contextlib import suppress, redirect_stdout | |
from collections import deque, OrderedDict | |
from weakref import ref | |
import re | |
class PDFRef: |
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 subprocess as subp | |
import pandas as pd | |
from matplotlib import pyplot as plt | |
p = subp.Popen(['tasklist', '/fo', 'csv'], stdout=subp.PIPE) | |
df = pd.read_csv(p.stdout, encoding='gbk') | |
df['mem'] = df['内存使用 '].transform(lambda x: int(x[:-2].replace(',', ''))) | |
df['proc'] = df['映像名称'] | |
df = df.groupby('proc')['mem'] \ | |
.agg(['sum', 'count']) \ |
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
from tkinter.filedialog import askdirectory | |
from tkinter import * | |
from tkinter.ttk import * | |
import subprocess | |
import weakref | |
import sys | |
import os | |
def human_size(cntbytes): |
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/env bash | |
TEMPDIR=$(mktemp -d) | |
cat >$TEMPDIR/input.txt | |
FZFOPTS="$(echo "$FZF_DEFAULT_OPTS" | sed 's/--height\s*\S*\s*//')" | |
for arg; do | |
FZFARGS="$FZFARGS \"$arg\"" | |
done | |
cat >$TEMPDIR/script.sh <<EOF |
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/env python3 | |
'''Parse logs in structures with the help of a pushdown automata. | |
Grammar for the sample log file: | |
>This line is used for exact match. | |
$This line is used for regexp match. | |
This line is ignored. | |
The following lines marked a repeated region. | |
!repeat |
OlderNewer