This file contains hidden or 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
| def _pdf_to_images_high_quality(pdf_path, dpi=200): | |
| images = [] | |
| with fitz.open(pdf_path) as pdf_document: | |
| zoom = dpi / 72.0 | |
| matrix = fitz.Matrix(zoom, zoom) | |
| for page_num in range(pdf_document.page_count): | |
| page = pdf_document[page_num] |
This file contains hidden or 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 asyncio | |
| import argparse | |
| import logging | |
| import json | |
| from copy import copy | |
| from typing import Optional, Iterable | |
| logger = logging.getLogger(__name__) | |
| # optional setup for optimizations |
This file contains hidden or 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 argparse | |
| import os | |
| import re | |
| import logging | |
| import shutil | |
| logging.basicConfig(format='%(levelname)s: %(message)s') | |
| _comment = re.compile(r'\\begin\{comment\}[\s\S]*\\end{comment}|(?<!\\)%.*\n') | |
| _empty_line = re.compile(r'\n\s*\n') |
This file contains hidden or 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 json | |
| import os | |
| def json2sql(json_path, sql_path, table_name, encoding='utf-8', is_multi_line=False): | |
| # read the data | |
| data = [] | |
| with open(json_path, 'r', encoding=encoding) as f: | |
| if is_multi_line: | |
| for line in f: |
This file contains hidden or 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 matplotlib.pyplot as plt | |
| plt.rc('text', usetex=True) | |
| plt.rc('font', family='serif') |
This file contains hidden or 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 | |
| # Exit on error | |
| set -e | |
| # Ensure script is running as root | |
| if [ "$EUID" -ne 0 ] | |
| then echo "WARN: Please run as root (sudo)" | |
| exit 1 | |
| fi |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <ifaddrs.h> | |
| // works on Linux and macOS | |
| #ifdef AF_LINK | |
| #include <net/if_dl.h> | |
| unsigned char *get_ptr(struct ifaddrs *ifaptr) | |
| { |
This file contains hidden or 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
| # Generate your identity key on openwrt | |
| dropbearkey -t rsa -f ~/.ssh/id_rsa | |
| # Convert public key from dropbear binary to openssh text | |
| # Copy and paste output from below to bitbucket account ssh keys | |
| dropbearkey -y -f ~/.ssh/id_rsa | head -n 2 | tail -1 | |
| # Change git ssh command | |
| echo "#!/bin/sh" > ~/.gitssh.sh | |
| echo "dbclient -y -i ~/.ssh/id_rsa \$\*" >> ~/.gitssh.sh |