Skip to content

Instantly share code, notes, and snippets.

Bash tips: Colors and formatting (ANSI/VT100 Control sequences)

The ANSI/VT100 terminals and terminal emulators are not just able to display black and white text ; they can display colors and formatted texts thanks to escape sequences. Those sequences are composed of the Escape character (often represented by “^[” or “<Esc>”) followed by some other characters: “<Esc>[FormatCodem”.

In Bash, the <Esc> character can be obtained with the following syntaxes:

  • `\e`
@Aero-Blue
Aero-Blue / telegram-bot.py
Created March 24, 2020 23:51
Telegram bot made with Telethon that sends a message to all members of a specified group
from telethon.sync import TelegramClient
import asyncio
from os import path
# Logging configuration
def login(phone, api_id, api_hash):
global client
client = TelegramClient(phone, int(api_id), api_hash)
@rdenadai
rdenadai / python_expert_path.md
Last active April 19, 2024 20:12
My take into build a basic structure to dictate how to become a Python Expert ... from basic to specialist ?

Python Expert Path

Beginner

  • Basic syntax
    • Variables types:
      • bool, int, float, str, byte, complex, None
    • Conditionals:
      • if, else, elif, for, while, match
  • Functions: simple use, and known what first class citizen is (concept)
@bmaupin
bmaupin / free-database-hosting.md
Last active April 19, 2024 20:08
Free database hosting
@0atman
0atman / configuration.nix
Last active April 19, 2024 20:06
A rebuild script that commits on a successful build
{
config,
pkgs,
options,
...
}: let
hostname = "oatman-pc"; # to alllow per-machine config
in {
networking.hostName = hostname;
@mackmm145
mackmm145 / extension-jump-anchor.js
Created January 16, 2022 22:14
TipTap jump anchor example
import { Mark, mergeAttributes } from '@tiptap/core'
export const jumpAnchor = Mark.create( {
name: "jumpAnchor",
addAttributes() {
return {
id: {
default: null,
parseHTML: element => element.getAttribute( 'id' ),
@zloedi
zloedi / roguelike_FOV.c
Last active April 19, 2024 20:02
Efficient roguelike grid FOV / shadowcasting / line of sight in a single C function inspired by https://docs.microsoft.com/en-us/archive/blogs/ericlippert/shadowcasting-in-c-part-one
// Copyright (c) 2021 Stoiko Todorov
// This work is licensed under the terms of the MIT license.
// For a copy, see https://opensource.org/licenses/MIT.
// What this function does:
// Rasterizes a single Field Of View octant on a grid, similar to the way
// field of view / line of sight / shadowcasting is implemented in some
// roguelikes.
// Uses rays to define visible volumes instead of tracing lines from origin
// to pixels.
@realvjy
realvjy / ChoasLinesShader.metal
Last active April 19, 2024 20:01
Choas Lines - Metal Shader
// Lines
float hash( float n ) {
return fract(sin(n)*753.5453123);
}
// Slight modification of iq's noise function.
float noise(vector_float2 x )
{
vector_float2 p = floor(x);
vector_float2 f = fract(x);
@alexkates
alexkates / how-to-trigger-lambda-from-sqs-stack.ts
Last active April 19, 2024 20:00
How to Trigger an AWS Lambda from SQS using the AWS CDK
// Import aws-cdk packages
import * as cdk from '@aws-cdk/core';
import * as sqs from '@aws-cdk/aws-sqs';
import * as lambda from '@aws-cdk/aws-lambda';
import * as lambdaEventSources from '@aws-cdk/aws-lambda-event-sources';
export class HowToTriggerLambdaFromSqsStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
@rkeithhill
rkeithhill / Optimize-PSReadlineHistory.ps1
Last active April 19, 2024 20:00
Removes duplicate and optionally short commands from your PSReadline history file
<#
.SYNOPSIS
Optimizes your PSReadline history save file.
.DESCRIPTION
Optimizes your PSReadline history save file by removing duplicate
entries and optionally removing commands that are not longer than
a minimum length
.EXAMPLE
C:\PS> Optimize-PSReadlineHistory
Removes all the duplicate commands.