Skip to content

Instantly share code, notes, and snippets.

View AnonymouX47's full-sized avatar
💭
Solving Problems...

AnonymouX47 AnonymouX47

💭
Solving Problems...
View GitHub Profile
@willmcgugan
willmcgugan / last_lines.py
Created March 2, 2024 16:10
Get the last lines from a file
import mmap
def get_last_lines(path: str, count: int) -> list[str]:
"""Get count last lines from a file."""
with open(path, "r+b") as text_file:
text_mmap = mmap.mmap(text_file.fileno(), 0, mmap.ACCESS_READ)
position = len(text_mmap)
while count and (position := text_mmap.rfind(b"\n", 0, position)) != -1:
count -= 1
@AlexWaygood
AlexWaygood / last_n_lines.py
Last active March 10, 2024 16:30
Script to find the last `n` lines of a file
import os
from collections import deque
from collections.abc import Iterator, Sequence
from typing import Final, Protocol
class SeekableBytesFile(Protocol):
def seek(self, position: int, whence: int = ..., /) -> int: ...
def read(self, amount: int, /) -> bytes: ...
@christianparpart
christianparpart / terminal-synchronized-output.md
Last active May 18, 2024 17:52
Terminal Spec: Synchronized Output

Synchronized Output

Synchronized output is merely implementing the feature as inspired by iTerm2 synchronized output, except that it's not using the rare DCS but rather the well known SM ? and RM ?. iTerm2 has now also adopted to use the new syntax instead of using DCS.

Semantics

When rendering the screen of the terminal, the Emulator usually iterates through each visible grid cell and renders its current state. With applications updating the screen a at higher frequency this can cause tearing.

This mode attempts to mitigate that.

@victor-iyi
victor-iyi / .vimrc
Last active May 19, 2021 11:09
My Vim configuration file
" File: ~/.vimrc
"
" Author: Victor I. Afolabi
syntax enable
colorscheme desert
" highlight Normal guibg=none
" =============================================================================
@egmontkob
egmontkob / Hyperlinks_in_Terminal_Emulators.md
Last active May 18, 2024 20:14
Hyperlinks in Terminal Emulators
@jdloft
jdloft / .bash_profile
Last active October 18, 2021 01:36 — forked from dylon/.bash_profile
How to get 256 colors in a standard Linux terminal + screen (without X windows).
# ...
# This is for what I would consider a standard setup, where TTY's 1 -- 6 are
# "linux" terminals and TTY's 7+ are reserved for X windows. You should adjust
# it to your setup, accordingly.
#
# ::: Important ::: You must have both fbterm and screen installed and on your
# path for this to work.
case $(tty) in /dev/tty[0-6]*)
@adeekshith
adeekshith / .git-commit-template.txt
Last active February 21, 2024 12:06 — forked from Linell/.git-commit-template.txt
This commit message template helps you write great commit messages and enforce it across teams.
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
@XVilka
XVilka / TrueColour.md
Last active April 8, 2024 14:02
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@dylon
dylon / .bash_profile
Last active September 9, 2023 14:51
How to get 256 colors in a standard Linux terminal + screen (without X windows).
# ...
# This is for what I would consider a standard setup, where TTY's 1 -- 6 are
# "linux" terminals and TTY's 7+ are reserved for X windows. You should adjust
# it to your setup, accordingly.
#
# ::: Important ::: You must have both fbterm and screen installed and on your
# path for this to work.
virtual_terminal="$( tty | grep -oE ....$ )"