Skip to content

Instantly share code, notes, and snippets.

View demiurg's full-sized avatar

Pavel demiurg

View GitHub Profile
@demiurg
demiurg / Eiffel-color-theme.json
Last active October 3, 2024 22:40
Eiffel Color Theme port for Zed
{
"name": "Eiffel",
"author": "",
"themes": [
{
"name": "Eiffel",
"appearance": "light",
"style": {
"border": "#c9c9caff",
"border.variant": "#dfdfe0ff",
@demiurg
demiurg / test_async_approaches.py
Created March 28, 2024 21:49
test_async_approaches.py
from concurrent.futures import ThreadPoolExecutor, wait
from multiprocessing import cpu_count
import asyncio
def proc(arg):
print(arg)
@demiurg
demiurg / aws_list_and_sign.py
Created March 9, 2023 20:09
presign s3 urls based on prefix
#!/usr/bin/env python3
import boto3
import argparse
def list_objects(bucket, prefix="", suffix=""):
s3 = boto3.client("s3")
paginator = s3.get_paginator("list_objects_v2")
for page in paginator.paginate(Prefix=prefix, Bucket=bucket):
@demiurg
demiurg / 00_moving_tasks.md
Last active July 16, 2024 00:25
Moving LXD container

Moving

  1. Install LXD on new server B, set remote access password
  2. Make A server container clone, upgrade ubuntu to 18.04 LTS
  3. Add A server LXD remote to B server
  4. Run command to copy app container to remote server B
  5. Install and setup Nginx (any http server) with to proxy server ports 80/443 to app container port 80 (A)
@demiurg
demiurg / cmf_compress.sh
Last active December 16, 2022 17:30
Compress CMF to UInt16
### Commands to add
# Preserving nodata scaling (0 - 26212 is only for CH4), we will have to have a different factor for CO2
gdal_calc.py --calc "numpy.around(numpy.clip(A, 0, 26212) * 2.5)" --NoDataValue=65535 --format=GTiff --type=UInt16 --co=COMPRESS=DEFLATE --co=ZLEVEL=9 --A_band=4 -A ../cmf/ang20161008t204651_cmf_v1n2_img --outfile=./ang20161008t204651_cmf_v1n2_img_cmf_i16.tif
# Set the scaling metadata
gdal_edit.py -scale 0.4 ./ang20161008t204651_cmf_v1n2_img_cmf_i16.tif
# RGB
gdal_translate -of GTiff -ot Byte -b 1 -b 2 -b 3 -scale -co COMPRESS=DEFLATE -co ZLEVEL=9 ../cmf/ang20161008t204651_cmf_v1n2_img ./ang20161008t204651_cmf_v1n2_img_rgb.tif
##########################

Carbon Mapper

Modified Creative Commons Attribution ShareAlike 4.0 International Public License

Effective Dates: November 9, 2021 – August 31, 2024

Carbon Mapper (the "Licensor") provides its data ("Data") to third parties for non-commercial purposes subject to this Modified Creative Commons Attribution ShareAlike 4.0 International Public License ("CC License"). Third party use of the Data shall at all times be subject to the CC License.

By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this modified Creative Commons Attribution ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.

@demiurg
demiurg / aws_rds_copy.sh
Created July 29, 2022 15:53
Copy RDS PG database without roles
#!/bin/bash
set -e
set -u
PS3='Migrate database for an environment. Please enter your choice: '
options=("dev" "uat" "prod" "Quit")
select opt in "${options[@]}"
do
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def numToLetter(number):
result = "";
charIndex = int(number % len(alphabet))
quotient = int(number / len(alphabet))
if (charIndex - 1 == -1):
charIndex = len(alphabet);
import numba as nb
from concurrent.futures import ThreadPoolExecutor
from multiprocessing import cpu_count
@nb.jit(nogil=True)
def slow_calculation(x):
out = 0
for i in range(x):
out += i**0.01
return out
Open RegEdit
Navigate to this Key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
Change “SecurityLayer” to a zero
Reboot and done!