Skip to content

Instantly share code, notes, and snippets.

View cyrillkuettel's full-sized avatar

Cyrill Küttel cyrillkuettel

  • Switzerland
View GitHub Profile
@cyrillkuettel
cyrillkuettel / mount_command_windows_from_linux.md
Last active March 21, 2022 21:02
Mount Windows parition from linux live system

Edit Files on windows partition from linux

If you've tried to edit windows files from linux, you might have encoutered the issue when trying to write to ntfs file system.

Read-only file system.

1.) First, we need to disable hibernation. Boot into your windows System. Open a cmd as Admin, and run powercfg /h off 2.) Shutdown windows. Then boot from the linux system you wish to access the windows partition. Run these commands to mount the windows partition.

@cyrillkuettel
cyrillkuettel / check_number_of_posix_threads_in_fastapi.md
Last active August 23, 2022 11:27
Get number of threads a uvicorn process using

See how many threads FastAPI is running on

If you have a simple FastAPI application you use uvicorn main:app --reload --port 4681 --host 0.0.0.0 with the following main.py

Simple demo app looks like this:

from fastapi import FastAPI
@cyrillkuettel
cyrillkuettel / mutliple_remote_url.md
Last active August 23, 2022 11:31
Add multiple remote origin urls to git

Show the curent remote origin url

git config --get remote.origin.url

Add multiple remote origins

git remote set-url --add --push origin git@<your_remote_url_here>
git remote set-url --add --push origin git@
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import jnettool.tools.elements.NetworkElement
import jnettool.tools.Routing
import jnettool.tools.RouteInsector
ne = jnettool.tools.elements.NetworkElement('171.0.2.45')
try:
routing_table = ne.getRoutingTable()
except jnettool.tools.elements.MissingVar:
logging.exception('No routing table found')
from nettools import NetworkElement
with NetworkElement('171.0.2.45') as ne:
for route in ne.routing_table:
print "%15s -> %s" % (route.name, route.ipaddr)
''' Pythonic means "coding beautifully in harmony with
the language to get the maximum benefits from Python"
Learn to recognize non-pythonic APIs and to recognize
good code. Don't get distracted by PEP 8. Focus
first an Pythonic versus NonPython (P vs NP).
When needed, write an adapter class to convert from
the former to the latter.
* Avoid unnecessart packageing in favor of
simpler imports

yt-dlp termux full installation guide.md

Prepare

  1. Install Termux from Github: https://github.com/termux/termux-app/releases
  2. Download the apk and install it -> Note that installing termux from Play Store is highly discouraged.

In Termux:

pkg update
class PathAdapter(PosixPath):
"""
Adapter to translate a Sub Filesystem from Pyfilesystem to Pathlib.
Use like this:
from fs import open_fs
from pathlib import Path, PosixPath
your_fs = open_fs('/tmp/test/')
@cyrillkuettel
cyrillkuettel / Overleaf_Custom_Vim_bindings.js
Created November 26, 2022 15:30
Demonstrates how to inject custom vim settings in CodeMirror 6 Editor.
// ==UserScript==
// @name Overleaf Custom Vim bindings
// @match https://www.overleaf.com/project/*
// @version 0.1
// @description Injecting custom vim settings in overleaf project. CodeMirror 6 editor only.
// @author cyrillkuettel
// @match https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo/related?hl=de
// @grant none
// ==/UserScript==