Skip to content

Instantly share code, notes, and snippets.

View nst's full-sized avatar

Nicolas Seriot nst

View GitHub Profile
@ole
ole / Mojave-dynamic-wallpaper-notes.md
Last active August 15, 2025 23:45
Reverse-engineering the dynamic wallpaper file format in macOS Mojave.

The dynamic wallpaper in MacOS Mojave is a single 114 MB .heic file that seems to contain 16 embedded images.

It also contains the following binary plist data in its metadata under the key "Solar". It's an array of 16 items, each with four keys:

  • i (integer). This seems to be the image index.
  • o (integer). This is always 1 or 0. Stephen Radford thinks it indicates dark mode (0) vs. light mode (1).
  • a (decimal). I’m pretty sure this is the angle of the sun over the horizon. 0º = sunset/sunrise. 90º = sun directly overhead. Negative values = sun below horizon.
  • z (decimal). This seems to be the cardinal position of the sun relative to the camera. 0º = sun is directly in front of the camera. 90º = sun is directly to the right of the camera. 180º = sun is directly behind the camera.
from github import Github
from pathlib import Path
from git import Repo
skip = ['UnrealEngine'] # a really big repo i want to skip
token = "xxxxxxxxxxx" # github personal access token
g = Github(token)
dest = Path('/repos/go/here') # save my cloned repos here
dest.mkdir(parents=True, exist_ok=True)
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
clist=[(1,1,1),(1,0,0)]
cm = LinearSegmentedColormap.from_list('wr',clist)
plt.register_cmap(cmap=cm)
clist=[(0,0,1),(1,1,1)]
@nst
nst / kovach_pycairo.py
Last active February 27, 2023 07:10
Reproducing Benjamin Kovach's art with pycairo
#!/usr/bin/env python
# Author: Nicolas Seriot
# Date: 2018-03-17
# Description: Reproducing Benjamin Kovach's art with pycairo
# https://www.kovach.me/Generating_artwork_with_Haskell.html
# Output: http://seriot.ch/visualization/kovach_pycairo.png
# Gist: https://gist.github.com/nst/3dc5378399678be7eb297ef18580025e
import cairo
@0xced
0xced / ActuallyLocalizedStringForStatusCode.m
Created November 15, 2017 15:40
Get a *localized* string for a given HTTP status code
#import <Foundation/Foundation.h>
static NSString * _Nonnull ActuallyLocalizedStringForStatusCode(NSInteger statusCode)
{
static NSBundle *cfNetworkBundle;
static dispatch_once_t once;
dispatch_once(&once, ^{
cfNetworkBundle = [NSBundle bundleForClass:NSHTTPURLResponse.class];
});
NSString *httpError = [NSHTTPURLResponse localizedStringForStatusCode:statusCode];
anonymous
anonymous / xcode.sh
Created November 9, 2017 17:20
#!/bin/bash
# Exit the script immediately on error
set -e
# We'll work in /tmp
cd /tmp
# Clone mach_override unless we already have it
if [ ! -d ~/mach_override ]; then
@marcan
marcan / gamma_trick.sh
Last active October 11, 2025 16:28
Two images in one using the PNG gamma header trick.
#!/bin/sh
# PNG Gamma trick (by @marcan42 / [email protected])
#
# This script implements an improved version of the gamma trick used to make
# thumbnail images on reddit/4chan look different from the full-size image.
#
# Sample output (SFW; images by @Miluda):
# https://mrcn.st/t/homura_gamma_trick.png
# https://www.reddit.com/r/test/comments/6edthw/ (click for fullsize)
# https://twitter.com/marcan42/status/869855956842143744
@wojteklu
wojteklu / clean_code.md
Last active December 12, 2025 01:36
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@s4y
s4y / editor.md
Last active April 14, 2018 10:45
A tiny little text editor that you can type as a URL

Simplest

data:text/html,<body contenteditable>

Monospace font, spell checking off

data:text/html,<body spellcheck=false style="font: 16px monospace" contenteditable>

URL updates as you type

//: Playground - noun: a place where people can play
import UIKit
protocol Foo {
}
protocol Bar {