Skip to content

Instantly share code, notes, and snippets.

@rootwork
rootwork / svg-to-pdf-cmyk.md
Last active January 23, 2025 10:23
Creating a 300dpi CMYK PDF from an SVG (on Linux)

Creating a 300dpi CMYK PDF from an SVG (on Linux)

SVGs generated from the web, and any SVGs from Inkscape, will be in the RGB colorspace. To convert it to CMYK for printing, there are basically two major steps: Converting the SVG to a PDF, and then converting the PDF from RGB to CMYK.

Note that CMYK and RGB are literally different types of color; there is not and cannot be a 1:1 correspondence between their colors, so if you need to regularly design for print you should be using CMYK from the beginning (not tacking it on at the end) -- and for that, unfortunately, the only option is Adobe Illustrator.

Anyway, this is what worked for me to convert an RGB SVG to a CMYK PDF with a specific DPI.

Untested options

@mdawaffe
mdawaffe / diff-changed-lines.sh
Last active March 25, 2025 11:24
Get line numbers of changed lines - git, diff - Full of bashisms
#!/bin/bash
# Call like you would `diff`
# `./diff-changed-lines.sh old new`
# Outputs the lines numbers of the new file
# that are not present in the old file.
# That is, outputs line numbers for new lines and changed lines
# and does not output line numbers deleted or unchanged lines.
@jbrown123
jbrown123 / -Recursive Queries Using Common Table Expressions.md
Last active October 10, 2024 00:02
Creating arbitrary-depth recursive queries in SQLITE (works for any SQL compliant system) using CTEs (common table expressions)

Recursive Queries Using Common Table Expressions

Common Table Expressions (CTEs) are a bit complex and difficult to understand at first blush. Many of the tutorials and examples on the net don't make it any easier for those just starting out. I thought I'd put together a quick gist that tries to simplify the concept and demonstrate how to do recursive queries using CTEs.

Keep in mind that CTEs have other uses besides just recursive queries but this gist is just about how they can be used to create recursive searches.

I'm using SQLite in this example but any SQL language that implements the WITH keyword should be able to do the same thing. If you've never used SQLite before, you are missing out on an amazing, open source, stand alone, SQL engine. I encourage you to check it out.

A practical example

@bikz05
bikz05 / histogram3D.py
Last active August 20, 2023 14:51
This python script demonstrates how we can use a 3D histogram in OpenCV to sort the colors and find the max color in a image.
# This python script demonstrates how we can use a 3D
# histogram in OpenCV to sort the colors and find the
# max color in a image
import cv2
import numpy as np
# Read the image
image = cv2.imread("/home/bikz05/Desktop/dataset/0.png");
@kergoth
kergoth / trap-set-e-test.sh
Last active June 22, 2023 16:33
Experimental verbose set -e handler for both bash and non-bash cases, with example use of BASH_ARG & BASH_ARGV. I realize enabling extdebug for an exceptional case isn't efficient, but I wanted sane example usage of those variables, so here it is.
#!/bin/sh
. $(dirname "$0")/trap.sh
set -e
foo () {
bar "$@" alpha beta
}