Skip to content

Instantly share code, notes, and snippets.

const http2 = require("http2");
const fs = require("fs");
const port = 8433;
const server = http2.createSecureServer({
key: fs.readFileSync("localhost.key"),
cert: fs.readFileSync("localhost.crt"),
});
import sys
from typing import Optional
from beancount.ingest import importer
sys.path.append("./")
import csv
from datetime import datetime
from datetime import timedelta
from beancount.core import data
import csv
import re
from collections import namedtuple
from datetime import date
from datetime import datetime
from datetime import timedelta
from typing import List
from beancount.core import data
from beancount.core.amount import Amount
@whtsky
whtsky / migrate-to-pytest-mypy-plugins.py
Created January 19, 2021 06:32
mypy test data to pytest-mypy-plugins
outputs=[]
with open('graphene_plugin.test', 'r') as f:
for x in f.read().strip().splitlines():
if x.startswith("[case "):
outputs.append(f"- case: {x.replace('[case', '').replace(']', '').strip()}")
outputs.append(" main: |")
elif x == "[out]":
outputs.append(" out: |")
else:
outputs.append(f" {x}")
{
"a": "a\b"
}
''.join([x for x in s if x.isprintable()])
#!/usr/bin/env python3
import shutil
import sys
from pathlib import Path
def handle_path(path: Path):
subfolders = []
seen_sdrs = set()
yarn config set puppeteer_download_host https://npm.taobao.org/mirrors
#!/bin/bash
clean_sdr_in_current_folder () {
find . -maxdepth 1 ! -path . -type d -print0 | while read -d $'\0' FOLDER
do
FOLDER=$(basename "$FOLDER")
if [[ $FOLDER == *".sdr" ]]; then
if [ -d "$FOLDER" -a ! -n "$(find . -maxdepth 1 -type f -name "${FOLDER%.sdr}*" -print -quit)" ]
then
echo "Remove $FOLDER"
Get-ChildItem -Path 'D:\PATH' -Filter *pptx -Recurse |
ForEach-Object -Begin {
$null = Add-Type -AssemblyName Microsoft.Office.Interop.powerpoint
$SaveOption = [Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType]::ppSaveAsPDF
$PowerPoint = New-Object -ComObject "PowerPoint.Application"
} -Process {
$Presentation = $PowerPoint.Presentations.Open($_.FullName)
$PdfNewName = $_.FullName -replace '\.pptx$','.pdf'
$presentation.SaveAs($PdfNewName,$SaveOption)
$presentation.close()