Skip to content

Instantly share code, notes, and snippets.

@fengyie007
fengyie007 / python-mac-set-html-clipboard.py
Last active January 18, 2023 13:35 — forked from mpcabd/python-mac-set-html-clipboard.py
Python3 - Set Mac clipboard with HTML content
import subprocess
html = '<p><strong>Hello</strong> <em>Bob</em> <code>How</code> are you!</p>'
def setClipboardData(html):
# print(html)
p_hex = subprocess.Popen(
('hexdump', '-ve', '1/1 "%.2x"'),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE
@fengyie007
fengyie007 / egos_throttle.sh
Created February 25, 2021 07:14 — forked from golimpio/egos_throttle.sh
Run cputhrottle for a list of applications in order to limit their CPU usage.
#!/bin/bash
# Run cputhrottle for a list of applications in order to limit their CPU usage.
# This script needs `pidof` and `cputhrottle` installed, which can be installed from homebrew.
# NOTE: This script was tested on MacOS only.
if [[ $EUID > 0 ]]; then
echo "Please run this script as root/sudo"
exit 1
fi
@fengyie007
fengyie007 / B64ImgReplacedElementFactory.java
Last active February 18, 2023 18:49 — forked from mping/B64ImgReplacedElementFactory.java
Using Data URLs for embedding images in Flying Saucer generated PDFs
import com.itextpdf.text.BadElementException;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.codec.Base64;
import org.w3c.dom.Element;
import org.xhtmlrenderer.extend.FSImage;
import org.xhtmlrenderer.extend.ReplacedElement;
import org.xhtmlrenderer.extend.ReplacedElementFactory;
import org.xhtmlrenderer.extend.UserAgentCallback;
import org.xhtmlrenderer.layout.LayoutContext;
import org.xhtmlrenderer.pdf.ITextFSImage;