Skip to content

Instantly share code, notes, and snippets.

@mbinna
mbinna / effective_modern_cmake.md
Last active May 11, 2024 09:00
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@gabrielmlinassi
gabrielmlinassi / hooks.ts
Last active May 11, 2024 08:58
useMediaQuery & useBreakpoints hooks for handling conditional rendering on multiple breakpoints (Adapted for Next.js)
// -------------------------
// useMediaQuery
import { useState, useEffect, useLayoutEffect } from "react";
export function useMediaQuery(query: string) {
const [matches, setMatches] = useState(false);
useEffect(() => {
const media = window.matchMedia(query);
@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 11, 2024 08:56
Swift Concurrency Manifesto
// ==UserScript==
// @name No YouTube Volume Normalization
// @namespace https://gist.github.com/abec2304
// @match https://www.youtube.com/*
// @grant none
// @version 2.1
// @author abec2304
// @description Enjoy YouTube videos at their true volume
// @inject-into content
// @run-at document-start
@gabonator
gabonator / password.txt
Last active May 11, 2024 08:54
HiSilicon IP camera root passwords
Summary of passwords by sperglord8008s, updated November 1. 2020. For login try "root", "default", "defaul" or "root"
00000000
059AnkJ
4uvdzKqBkj.jg
7ujMko0admin
7ujMko0vizxv
123
1111
1234

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
int64_t ipow(int64_t base, uint8_t exp) {
static const uint8_t highest_bit_set[] = {
0, 1, 2, 2, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 255, // anything past 63 is a guaranteed overflow with base > 1
OS X is the platform, Darwin is the operating system, and XNU is the kernel. Namely, the XNU kernel is the core piece of software that provides resource management, hardware abstraction, and scheduling. Darwin consists of the XNU kernel and basic software run by there kernel to provide a UNIX environment. OS X is built atop Darwin and provides a collection of frameworks and services that implement the user interface and main application libraries. Darwin and XNU are open source software, but the frameworks that make up the OS X platform on top of Darwin, are not.
Ubuntu and other distributions are based on the Linux kernel and GNU software suite. Ubuntu is the platform, Linux + GNU is the operating system, and Linux is the kernel (more or less). Unlike OS X, Ubuntu doesn't have proprietary frameworks - everything is open source. And the distinction between the OS and platform are blurred as a result. That's why it's called a distribution, because what distinguishes Ubuntu from other Linux distributions is mo
@sbyx
sbyx / low-battery-level-detection-notification-for-all-battery-sensors.yaml
Last active May 11, 2024 08:49
Home Assistant Blueprint: Low battery level detection & notification for all battery sensors
blueprint:
name: Low battery level detection & notification for all battery sensors
description: Regularly test all sensors with 'battery' device-class for crossing
a certain battery level threshold and if so execute an action.
domain: automation
input:
threshold:
name: Battery warning level threshold
description: Battery sensors below threshold are assumed to be low-battery (as
well as binary battery sensors with value 'on').
@RealFatCat
RealFatCat / main.go
Created June 6, 2023 14:24
example of go-tc u32 filter with nat action
package main
import (
"fmt"
"net"
"os"
"syscall"
"github.com/mdlayher/netlink"