Skip to content

Instantly share code, notes, and snippets.

@GetVladimir
GetVladimir / Force-RGB-Color-on-M1-Mac.md
Last active April 23, 2024 17:06
Force RGB Color on M1 Mac

Force RGB Color on M1 Mac

How to Force RGB Color Output instead of YPbPr on your M1 Apple Silicon Mac for an External Monitor.

This step-by-step video tutorial will guide you through the procedure of forcing RGB color output on your M1 Mac.

Force RGB Color on M1 Mac

Here is the direct link to the video tutorial: https://www.youtube.com/watch?v=Z1EqH3fd0V4

The video also has Closed Captions (Subtitles) that you can enable, to make it easier to follow if needed.

@sindresorhus
sindresorhus / esm-package.md
Last active April 24, 2024 09:47
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@tsmx
tsmx / got-authorization-header.js
Last active August 2, 2022 13:43
Set authorization header with bearer-token in got.
const got = require('got');
// get 'url' and 'token'...
got.get(url), {
responseType: 'json',
hooks: {
beforeRequest: [
options => {
options.headers['Authorization'] = 'Bearer ' + token;
@avaidyam
avaidyam / BackdropView.swift
Created July 2, 2020 17:23
DIY NSVisualEffectView using Private API for macOS
// TODO: setting window transforms (or mission control) flattens layers...
// TODO: Mask image vs path (layer)?
/// `NSVisualEffectView`:
///
/// A view that adds translucency and vibrancy effects to the views in your interface.
/// When you want views to be more prominent in your interface, place them in a
/// backdrop view. The backdrop view is partially transparent, allowing some of
/// the underlying content to show through. Typically, you use a backdrop view
/// to blur background content, instead of obscuring it completely. It can also
@chriszielinski
chriszielinski / NSViewController+NSTextField.swift
Last active February 8, 2024 23:23
NSViewController extension for fetching a window title's NSTextField
extension NSViewController {
var titlebarTextField: NSTextField? {
// NSTitlebarContainerView
guard let titlebarContainerView = view.superview?.subviews
.first(where: { $0.className.hasSuffix("ContainerView") })
else { return nil }
// NSTitlebarView
guard let titlebarView = titlebarContainerView.subviews
@huksley
huksley / disabling-photoanalysisd.md
Last active March 27, 2024 17:28
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)

class LifespanManager:
def __init__(self, app):
self.app = app
self.startup_complete = asyncio.Event()
self.shutdown_complete = asyncio.Event()
self.messages = [{'type': 'lifespan.startup'}, {'type': 'lifespan.shutdown'}]
async def __aenter__(self):
self.task = asyncio.create_task(self.app(self.receive, self.send))
await self.startup_complete.wait()
@evenfrost
evenfrost / highlight.ts
Last active April 20, 2024 16:37
Fuse.js with highlight
const highlight = (fuseSearchResult: any, highlightClassName: string = 'highlight') => {
const set = (obj: object, path: string, value: any) => {
const pathValue = path.split('.');
let i;
for (i = 0; i < pathValue.length - 1; i++) {
obj = obj[pathValue[i]];
}
obj[pathValue[i]] = value;
@fnky
fnky / ANSI.md
Last active April 24, 2024 21:19
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27