Skip to content

Instantly share code, notes, and snippets.

View danmichaelo's full-sized avatar

Dan Michael O. Heggø danmichaelo

View GitHub Profile
@PhilippHomann
PhilippHomann / app.py
Last active August 7, 2024 07:36
FastAPI file upload with streaming_form_data to parse multipart/form-data
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
@fnky
fnky / ANSI.md
Last active June 13, 2025 17:50
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@stecman
stecman / _readme.md
Last active January 18, 2025 14:31
Brother P-Touch PT-P300BT bluetooth driver python

Controlling the Brother P-Touch Cube label maker from a computer

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.

Process

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
{
@aboutte
aboutte / Vagrantfile
Created August 23, 2016 14:55
Vagrantfile to set some time synchronization configs
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
@glogiotatidis
glogiotatidis / remove-gpg-user.sh
Created May 24, 2016 11:50
Git-crypt remove user.
#!/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.
@hossman
hossman / .bashrc.gitsanity.sh
Last active April 14, 2016 21:54
Life got so much better once i added this to my bashrc: git_sanity
# 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
@drblue
drblue / fix_onedrive.sh
Last active May 17, 2025 18:19
Fix OneDrive for Mac CPU usage
#!/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 {} +
@a0s
a0s / brew-cask-cleanup.rb
Last active November 5, 2019 14:14
Clean (move to trash) old brew cask versions
#!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 })
@jweisman
jweisman / harvest.rb
Last active September 3, 2015 08:23
Harvest OAI to AWS CloudSearch
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