Skip to content

Instantly share code, notes, and snippets.

View dhruvmanila's full-sized avatar
🎯
Focusing

Dhruv Manilawala dhruvmanila

🎯
Focusing
View GitHub Profile
@oliverdaff
oliverdaff / tracing-instrument-macro.md
Created January 4, 2024 01:13
Tutorial on Using the tracing::instrument Macro in Rust

Tutorial on Using the tracing::instrument Macro in Rust

Introduction

This document provides a comprehensive guide on using the tracing::instrument macro in Rust. It covers the basics of the tracing crate, the purpose and functioning of the instrument macro, and best practices for its effective use in software development.

What is the tracing::instrument Macro?

  • Overview: The tracing crate is a collection of Rust libraries for application-level tracing and asynchronous diagnostics. It provides a framework for collecting structured, event-based diagnostic information. The instrument macro, specifically, is a part of this crate. It automatically attaches context-specific information to logs, such as function arguments and return values, making it easier to track the flow and performance of the code.

  • Purpose: The primary purpose of the tracing::instrument macro is to aid in diagnostics and performance analysis. By annotating functions with this macro, developers can automatic

@folke
folke / lua-lsp.lua
Last active March 7, 2023 19:17
Correct sumneko lua lsp setup for init.lua and plugin development
-- put this file somewhere in your nvim config, like: ~/.config/nvim/lua/config/lua-lsp.lua
-- usage: require'lspconfig'.sumneko_lua.setup(require("config.lua-lsp"))
local library = {}
local path = vim.split(package.path, ";")
-- this is the ONLY correct way to setup your path
table.insert(path, "lua/?.lua")
table.insert(path, "lua/?/init.lua")
@runiq
runiq / README.md
Last active July 9, 2024 15:35
Neovim throttle & debounce

What are these?

Functions that allow you to call a function not more than once in a given timeframe.

Throttling on the leading edge

This can be illustrated with timing diagrams. In the following diagrams, f designates call to the throttled function, t is the period where the timer is running, and x shows you the actual execution point of the throttled function.

f 1  2  3  4  5  6
@Meorawr
Meorawr / async.lua
Last active September 8, 2024 20:17
Lua 5.1 Async/Await
#!/usr/bin/lua5.1
--- Async/Await for Lua 5.1
-- This script implements async/await functions for Lua, allowing tasks to
-- be queued and scheduled independently.
--
-- This is just an example and has a bunch of issues, isn't tested, isn't
-- even actually used anywhere; I basically just got bored and had one of
-- those "what if?" type ideas 6 hours ago.
local co_create = coroutine.create
@fnky
fnky / ANSI.md
Last active March 2, 2025 13:52
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@tanyuan
tanyuan / smart-caps-lock.md
Last active February 23, 2025 08:43
Smart Caps Lock: Remap Caps Lock to Control AND Escape

Smart Caps Lock: Remap to Control AND Escape (Linux, Mac, Windows)

Caps Lock 變成智慧的 Control 以及 Escape

  • 單獨輕按一下就是 Escape
  • 若按下時同時按著其他鍵,就會是 Control

這應該是 Vim 和 Emacs 的最佳解了!(Emacs? Bash 的快捷鍵就是 Emacs 系列的)

  • Send Escape if you tap Caps Lock alone.
@ccstone
ccstone / References For Learning & Using Applescript.md
Last active December 22, 2024 20:07
References For Learning & Using Applescript

REFERENCES FOR LEARNING & USING APPLESCRIPT Modified: 2018/06/19 18:47


NOTES

AppleScript is a rather peculiar scripting language to learn.

from __future__ import absolute_import
import signal
import gevent
import gevent.pool
from rq import Worker
from rq.timeouts import BaseDeathPenalty, JobTimeoutException
from rq.worker import StopRequested, green, blue
from rq.exceptions import DequeueTimeout
@ejdyksen
ejdyksen / patch-edid.md
Last active December 7, 2024 10:47
A script to fix EDID problems on external monitors in macOS

patch-edid.rb

A script to fix EDID problems on external monitors in macOS.

Instructions

  1. Connect only the problem display.

  2. Create this directory structure (if it doesn't already exist):