Skip to content

Instantly share code, notes, and snippets.

@romainl
romainl / colorscheme-override.md
Last active April 27, 2024 15:36
The right way to override any highlighting if you don't want to edit the colorscheme file directly

The right way to override any highlighting if you don't want to edit the colorscheme file directly

Generalities first

Suppose you have weird taste and you absolutely want:

  • your visual selection to always have a green background and black foreground,
  • your active statusline to always have a white background and red foreground,
  • your very own deep blue background.
@NickyMeuleman
NickyMeuleman / lib.rs
Created July 8, 2021 15:17
Rust .collect() an iterator into a HashMap
use std::collections::{HashMap, HashSet};
fn count_occurrences(message: &str) -> HashMap<char, usize> {
let unique: HashSet<char> = message.chars().collect();
unique
.iter()
.map(|&c| (c, message.matches(c).count()))
.collect()
}
@dvf
dvf / change-codec.md
Last active April 27, 2024 15:35
Enable High Quality mode on your headphones (Updated for macOS Catalina)

If you're using a high-end bluetooth headset on your Macbook Pro it's likely your mac is using an audio codec which favors battery efficiency over high quality. This results in a drastic degradation of sound, the SBC codec is the likely culprit, read more about it here.

Find out what codec you're using

  1. Play a song on your headphones
  2. Option (⌥) click the Bluetooth button at the top of your screen Inspect the Bluetooth Coded
  3. If you're using AAC or aptX, you can stop here—those are the highest quality codecs.

Change your codec to AAC or aptX

@CrendKing
CrendKing / !README.md
Last active April 27, 2024 15:33 — forked from mmozeiko/!README.md
Download MSVC compiler/linker & Windows SDK without installing full Visual Studio

This downloads standalone 64-bit MSVC compiler, linker & other tools, also headers/libraries from Windows SDK into portable folder, without installing Visual Studio. Has bare minimum components - no UWP/Store/WindowsRT stuff, just files & tools for 64-bit native desktop app development.

Run python.exe portable-msvc.py and it will download output into msvc folder. By default it will download latest available MSVC & Windows SDK - currently v14.32.17.2 and v10.0.22621.0.

You can list available versions with python.exe portable-msvc.py --show-versions and then pass versions you want with --msvc-version and --sdk-version arguments.

To use cl.exe/link.exe from output folder, first run setup.bat - after that PATH/INCLUDE/LIB env variables will be setup to use all the tools as usual. You can also use clang-cl.exe with these includes & libraries.

To use clang-cl.exe without running setup.bat, pass extra /winsysroot msvc argument (msvc is folder name where output is stored).

@chadaustin
chadaustin / colortest.rs
Created January 2, 2024 04:52
Detect Terminal Color and Character Attribute Support
#!/usr/bin/env -S rust-script -t nightly
#![feature(unix_sigpipe)]
use std::cmp::max;
const BASIC_COLORS: &[&str] = &[
"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white",
];
fn title(t: &str) {
@Alecton4
Alecton4 / icons.all.ts
Created September 28, 2023 10:22
List of all Elastic UI Icons with `appendIconComponentCache`
// NOTE: This file exists because of a known issue with EUI.
import { ICON_TYPES } from "@elastic/eui";
import { appendIconComponentCache } from "@elastic/eui/es/components/icon/icon";
import { icon as accessibility } from "@elastic/eui/es/components/icon/assets/accessibility";
import { icon as addDataApp } from "@elastic/eui/es/components/icon/assets/app_add_data";
import { icon as advancedSettingsApp } from "@elastic/eui/es/components/icon/assets/app_advanced_settings";
import { icon as agentApp } from "@elastic/eui/es/components/icon/assets/app_fleet";
import { icon as aggregate } from "@elastic/eui/es/components/icon/assets/aggregate";
import { icon as analyzeEvent } from "@elastic/eui/es/components/icon/assets/analyzeEvent";
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active April 27, 2024 15:29
set -e, -u, -o, -x pipefail explanation
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Calculadora</title>
<script src="calculadora.js"></script>
</head>
<body bgcolor="beige">
<h1>Calculadora 1.0</h1>
<input type="text" id="txtValor1">
@craiglabenz
craiglabenz / chat_message_render_box.dart
Last active April 27, 2024 15:27
Demonstrates a custom RenderObject that draws chat messages like WhatsApp, where the `sentAt` timestamp is tucked into the last line if it fits
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@NDHOMOU
NDHOMOU / hello.c
Last active April 27, 2024 15:22
mon hello world
int main()
{
printf("Hello world");
return 0;
}