Skip to content

Instantly share code, notes, and snippets.

@oantolin
oantolin / contrast.c
Last active October 19, 2024 12:09
Find most luminous contrasting color
#include <math.h>
#include <stdio.h>
double f(int c) {
double x = c / 255.0;
return x<=0.03928 ? x/12.92 : pow((x + 0.055)/1.055, 2.4);
}
double rellum(int r, int g, int b) {
return 0.2126*f(r) + 0.7152*f(g) + 0.0722*f(b);
@huksley
huksley / disabling-photoanalysisd.md
Last active August 11, 2025 21:42
Disabling photoanalysisd

For what it's worth (and with all the usual disclaimers about potentially making your mac unstable by disabling system services), here's some commands that will manipulate this service and services like it. Note the $UID in the command, that's just a bash shell variable that will resolve to some number. That's your numeric UID. You just run these commands from a Terminal command line. No special privileges needed.

If you want to disable it entirely, the first command stops it from respawning, and the second kills the one that is currently running:

launchctl disable gui/$UID/com.apple.photoanalysisd
launchctl kill -TERM gui/$UID/com.apple.photoanalysisd

(If you kill it without disabling it will die, but a new one will respawn and pick up where the old one left off)

@maliarslan
maliarslan / node-app-as-service-on-ubuntu.md
Last active May 26, 2024 10:19
Run Node.js application as service on Ubuntu 16.04

Assuming that you have already installed Node.js on your system. If you haven't visit https://nodejs.org/en/download/package-manager/

First we need to create a service file into /lib/systemd/system to introduce our service.

So, with your favorite editor, open up a new file there with;

sudo nano /lib/systemd/system/mygreatestapp.service

Put the following contents in it;

[Unit]