Skip to content

Instantly share code, notes, and snippets.

@fnky
fnky / ANSI.md
Last active May 17, 2024 16:33
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@simonw
simonw / recover_source_code.md
Last active May 17, 2024 16:32
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@mark-cooper
mark-cooper / OCLCCatcher.java
Created April 11, 2012 23:46
Batch edit ContentDM records using Catcher
package org.sonomalibrary.catcher;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@scottopell
scottopell / fix_exfat_drive.md
Last active May 17, 2024 16:32
Fix corrupted exFAT disk macOS/OSX

exFAT support on macOS seems to have some bugs because my external drives with exFAT formatting will randomly get corrupted.

Disk Utility is unable to repair this at first, but the fix is this:

  1. Use diskutil list to find the right drive id.
  2. You want the id under the IDENTIFIER column, it should look like disk1s1
  3. Run sudo fsck_exfat -d <id from above>. eg sudo fsck_exfat -d disk1s3
  4. -d is debug so you'll see all your files output as they're processed.
  5. Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
@nkhitrov
nkhitrov / structlog_fastapi.py
Created March 16, 2023 00:04
Structlog FastAPI example
"""
Structlog example configuration with FastAPI.
Features:
- async bound logger
- contextvars to log request-id and other meta data
- custom format for default logging loggers and structlog loggers
"""
import asyncio
import logging
@ziritrion
ziritrion / vm_containers.md
Last active May 17, 2024 16:29
Cheatsheet for various container and VM thingies

Docker

Terminology

  • Container: environment that runs an applications that is not dependent on the OS. Kind of like a lightweight VM. Containers are stateless; if you need to update the components inside, create another container instead.
  • Image: template to create a container. Its components are defined by a Dockerfile.
  • Volume: storage area detached from the container for maintaining state. There are 4 types:
    • Volumes: managed by Docker itself, they're stored in a separate part of the host filesystem (on Linux by default this would be var/lib/docker/volumes). Useful for production deployments.
    • Bind mounts: mount a specific directory or file from the host to the container, such as a project folder. Useful for development.
  • Tmpfs mounts: mount a temporary file system in the container, which is stored in the host system's memory only, not on disk. Useful for sensitive information that should not be persisted between container restarts or for performance reaso
@ziritrion
ziritrion / git.md
Last active May 17, 2024 16:29
git cheatsheet

Basic git

  1. Make sure your local copy of the selected branch is updated.
    1. Without overwriting anything
      • git fetch
    2. If you already fetched or you are ready to overwrite your local copy, then pull
      • git pull
  2. Check your repo branches
    1. Local branches
  • git branch
@svet-b
svet-b / bigdashboard_output.pdf
Last active May 17, 2024 16:29
PDF export of Grafana dashboard using puppeteer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rxaviers
rxaviers / gist:7360908
Last active May 17, 2024 16:28
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue: