pip install psutil
./safe_run.py bash long_script.sh
#!/usr/bin/env python3 | |
# coding: utf-8 | |
# | |
""" | |
Refs: | |
- https://jinja.palletsprojects.com/en/3.1.x/templates/ | |
- https://stackoverflow.com/questions/39288706/jinja2-load-template-from-string-typeerror-no-loader-for-this-environment-spec | |
改进型的yaml,支持符号~,增加默认配置redirect_stderr,stopasgroup,killasgroup,directory,user,stdout_logfile_backups=1,environment增加PATH |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import cv2 | |
import numpy as np | |
def _cv2open(filename, arg=0): | |
obj = cv2.imread(filename, arg) | |
if obj == None: | |
raise IOError('cv2 read file error:'+filename) |
const puppeteer = require('puppeteer'); | |
const resolve = require("path").resolve; | |
// node html2image.js -i input.html -o output.png | |
(async () => { | |
var program = require("commander"); | |
program | |
.version("0.1.0") | |
.option("-i, --input <path>", "input html") |
package main | |
import ( | |
"encoding/base64" | |
"flag" | |
"fmt" | |
"io" | |
"net" | |
"net/http" | |
"strings" |
# coding: utf-8 | |
# | |
from PIL import Image, ImageDraw | |
class Notch(object): | |
def __init__(self, d): | |
self.d = d | |
self.brand = self.d.device_info['brand'] | |
self.model = self.d.device_info['model'] |
[[0 1 2 3 4 5 6] | |
[1 2 3 4 5 6 7] | |
[2 3 2 4 6 7 8] | |
[3 4 3 2 4 6 8] | |
[4 5 4 3 2 4 6] | |
[5 6 5 4 3 5 7] | |
[6 7 6 5 4 6 5] | |
[7 8 7 6 5 7 6]] | |
[[1 1 1 1 1 1 1] | |
[0 0 0 0 0 0 0] |
package main | |
import ( | |
"log" | |
"net/http" | |
"sync" | |
"github.com/gorilla/websocket" | |
) |
package main | |
import ( | |
"fmt" | |
"log" | |
"time" | |
) | |
type Record struct { | |
a int |
#!/bin/bash | |
# | |
# | |
Echo(){ | |
echo ">>> $(date "+%Y-%m-%d %H:%M:%S")" "$@" | |
} | |
Die(){ Echo "$@"; exit 1; } |