Skip to content

Instantly share code, notes, and snippets.

@simonw
simonw / recover_source_code.md
Last active May 17, 2024 15:16
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
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.macos` has finished
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
@AfroThundr3007730
AfroThundr3007730 / sysprep_linux.sh
Last active May 17, 2024 15:14
Cloning preparation script for linux systems.
#!/bin/bash
# Does the equivalent of sysprep for linux boxes to prepare them for cloning.
# Based on https://lonesysadmin.net/2013/03/26/preparing-linux-template-vms/
# For issues or updated versions of this script, browse to the following URL:
# https://gist.github.com/AfroThundr3007730/ff5229c5b1f9a018091b14ceac95aa55
# SPDX-License-Identifier: GPL-3.0-or-later
AUTHOR='AfroThundr'
BASENAME="${0##*/}"
MODIFIED='20240409'
@MrLuje
MrLuje / gist:90264db02f99672de05686a6cb08c4f3
Created April 17, 2024 10:12
for loop in custom operation CE
open System
open System.Diagnostics
type PageConfig =
{ Text: string }
static member Default = { Text = "" }
type PageConfigOutput = PageConfigOutput of string
@andersevenrud
andersevenrud / alacritty-tmux-vim_truecolor.md
Last active May 17, 2024 15:14
True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

This should make True Color (24-bit) and italics work in your tmux session and vim/neovim when using Alacritty (and should be compatible with any other terminal emulator, including Kitty).

Testing colors

Running this script should look the same in tmux as without.

curl -s https://gist.githubusercontent.com/lifepillar/09a44b8cf0f9397465614e622979107f/raw/24-bit-color.sh >24-bit-color.sh
@aamiaa
aamiaa / CompleteDiscordQuest.md
Last active May 17, 2024 15:14
Complete Recent Discord Quest

Complete Recent Discord Quest

Note

This no longer works in browser!

Note

This no longer works if you're alone in vc! Somebody else has to join you!

How to use this script:

  1. Accept the quest under User Settings -> Gift Inventory
extension Task where Failure == Error {
// Start a new Task with a timeout. If the timeout expires before the operation is
// completed then the task is cancelled and an error is thrown.
init(priority: TaskPriority? = nil, timeout: TimeInterval, operation: @escaping @Sendable () async throws -> Success) {
self = Task(priority: priority) {
try await withThrowingTaskGroup(of: Success.self) { group -> Success in
group.addTask(operation: operation)
group.addTask {
try await _Concurrency.Task.sleep(nanoseconds: UInt64(timeout * 1_000_000_000))
[<Erase>]
type IProp<'comp when 'comp : not struct> = | Prop of string * obj
with
static member inline Create (value: string * obj) = Prop value
static member inline Build(props: IProp<'comp> seq) = props |> unbox<(string * obj) seq> |> createObj |> unbox<'comp>
let inline (!<) x = IProp.Build x
module Interop =
let inline mkProperty<'Component when 'Component : not struct> (key:string) (value:obj) : IProp<'Component> =
@Horusiath
Horusiath / Prolog.fs
Last active May 17, 2024 15:12
Yata move algorithm
namespace Demos
open System
type ReplicaId = String
[<RequireQualifiedAccess>]
module Array =