Skip to content

Instantly share code, notes, and snippets.

@gjoseph92
gjoseph92 / lp2844-macos-notes.md
Last active September 14, 2025 19:08
Notes on printing better quality labels using LPrint

The built-in driver for the Zebra LP2844 on macOS ("Zebra EPL2 Label Printer", see https://youtu.be/DT6gnpzzU60) gives pretty crappy print quality.

The latest (unreleased, as of Aug 2023) version of LPrint does better, see michaelrsweet/lprint#91 (comment).

I think the new "special algorithm" doesn't actually do much. It may just be that print-color-mode=bi-level, aka Print Mode: Text (which thresholds the image instead of trying to use dithering to cover the whole grayscale range) wasn't actually working in 1.2.0, and all the changes with the new algorithm accidentally fixed that bug. I see no visible difference between bi-level and monochrome; monochrome should, in theory, be thresholding only the parts that "look like a barcode", leaving the other parts dithered like before, whereas bi-level should be thresholding the whole thing.

@gjoseph92
gjoseph92 / README.md
Last active June 6, 2023 13:25
Share speedscope profiles in GitHub issues

An easy way to share speedscope profiles in GitHub issues

Speedscope is an excellent profile viewer. Maybe you're recorded a profile with py-spy and you want to show it to other people in a GitHub issue. The speedscope app can render profiles from a URL, but where do you store the profile?

You can do this easily with gists, githack, and a little script:

Installation:

@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active November 10, 2025 03:11
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@christopherscott
christopherscott / ExcelToJsDate.js
Created May 24, 2012 16:40
Convert Excel date values to JavaScript date objects
// Convert Excel dates into JS date objects
//
// @param excelDate {Number}
// @return {Date}
function getJsDateFromExcel(excelDate) {
// JavaScript dates can be constructed by passing milliseconds
// since the Unix epoch (January 1, 1970) example: new Date(12312512312);