Standard escape codes are prefixed with Escape:
- Ctrl-Key:
^[ - Octal:
\033 - Unicode:
\u001b - Hexadecimal:
\x1B - Decimal:
27
| from fastapi import FastAPI, UploadFile, HTTPException | |
| from starlette.requests import Request | |
| from streaming_form_data import StreamingFormDataParser | |
| from streaming_form_data.targets import FileTarget | |
| from tempfile import NamedTemporaryFile | |
| import os | |
| import shutil |
The Brother PTP300BT label maker is intended to be controlled using the official Brother P-Touch Design & Print iOS/Android app. The app has arbitrary limits on what you can print (1 text object and up to 3 preset icons), so I thought it would be a fun challenge to reverse engineer the protocol to print whatever I wanted.
Python code at the bottom if you want to skip the fine details.
Intitially I had a quick peek at the Android APK to see if there was any useful information inside. The code that handles the communication with the printer in Print&Design turned out to be a native library, but the app clearly prepares a bitmap image and passes it to this native library for printing. Bitmaps are definitely something we can work with.
| <?php | |
| //place me in /plugins/MyPlugin/lib/HiLifeAdminTheme/Plugin.php | |
| namespace MyPlugin; | |
| use Pimcore\API\Plugin as PluginLib; | |
| class Plugin extends PluginLib\AbstractPlugin implements PluginLib\PluginInterface | |
| { |
| Vagrant.configure("2") do |config| | |
| config.vm.provider :virtualbox do |virtualbox| | |
| # set timesync parameters to keep the clocks better in sync | |
| # sync time every 10 seconds | |
| virtualbox.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-interval", 10000 ] | |
| # adjustments if drift > 100 ms | |
| virtualbox.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-min-adjust", 100 ] | |
| # sync time on restore | |
| virtualbox.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-on-restore", 1 ] | |
| # sync time on start |
| #!/bin/bash | |
| # | |
| # Script to remove GPG key from git-crypt | |
| # | |
| # It will re-initialize git-crypt for the repository and re-add all keys except | |
| # the one requested for removal. | |
| # | |
| # Note: You still need to change all your secrets to fully protect yourself. | |
| # Removing a user will prevent them from reading future changes but they will | |
| # still have a copy of the data up to the point of their removal. |
| # git sanity | |
| function sane_git { | |
| if [[ $1 == "pull" ]]; then | |
| echo "Don't be a schmuck!"; | |
| echo | |
| echo "Use 'git fetch' and then merge/rebase as appropriate like a sane person." | |
| echo | |
| else | |
| "`which git`" $@ | |
| fi |
| #!/bin/bash | |
| ## Fix OneDrive for Mac CPU usage | |
| ## | |
| ## Seems this is still a problem 5 years later after I created this little gist. | |
| ## I have long since stopped using OneDrive (luckily), but according to | |
| ## comments below, I have added the new path for OfficeFileCache for macOS | |
| ## Mojave (10.14) and Catalina (10.15). | |
| ## Run this on macOS Mojave (10.14) and Catalina (10.15) | |
| find ~/Library/Containers/ -type d -name OfficeFileCache -exec rm -r {} + |
| #!ruby | |
| # Requirements: | |
| # brew install trash | |
| casks_path = '/opt/homebrew-cask/Caskroom' | |
| class Version < Array | |
| def initialize s | |
| super(s.split('.').map { |e| e.to_i }) |
| require 'rest-client' | |
| require 'nokogiri' | |
| require 'aws-sdk-core' | |
| def process_oai(inst, qs, domain, alma) | |
| oai_base = "https://#{alma}.alma.exlibrisgroup.com/view/oai/#{inst}/request" | |
| log "Calling OAI with query string #{qs}" | |
| oai = RestClient.get oai_base + qs |