Skip to content

Instantly share code, notes, and snippets.

@borgstrom
borgstrom / human_time_duration.py
Created May 9, 2018 04:00
Python: Convert seconds (duration) to human readable string
TIME_DURATION_UNITS = (
('week', 60*60*24*7),
('day', 60*60*24),
('hour', 60*60),
('min', 60),
('sec', 1)
)
def human_time_duration(seconds):
@mihaidusmanu
mihaidusmanu / rec_stats.py
Created October 24, 2020 14:48
COLMAP covisibility
def compute_reconstruction_statistics(reference_model_path):
# Images w. intrinsics and extrinsics.
with open(os.path.join(reference_model_path, 'cameras.txt'), 'r') as f:
raw_cameras = f.readlines()[3 :]
cameras = {}
for raw_line in raw_cameras:
split_line = raw_line.strip('\n').split(' ')
cameras[int(split_line[0])] = split_line[1 :]
@moiri
moiri / backend.ts
Last active April 24, 2024 06:48
Type Conversions from String to MongoDB ObjectId
import { ObjectId } from 'mongodb';
/* Use this to extend any interface with an `_id` property of type OID */
export type TWithOid<T extends {}> = T & {
_id: ObjectId;
};
/**
* Replaces a string property with the same property of type ObjectId.
@philmcmahon
philmcmahon / qubes-blogpost-ben-grande-feedback.txt
Created April 9, 2024 17:58
Feedback on Qubes/Salt blogpost from Ben Grande
- Always enforce preferences on the `qvm.prefs` module: many times I see
`label` only in `qvm.present`, which is only run on creation of the
qube, not when it already exists. The `qvm.prefs` module is checked
everytime even if the qube already exists. I think label should be
enforced not let for the user to modify and then later the state
ignore the label change, but of course I don't know your internal
policy about this matter and I might be wrong depending on it.
- Do not specify literal names as the `source` value of `qvm.clone`,
aahed
aalii
aapas
aargh
aarti
abaca
abaci
aback
abacs
abaft
import 'dart:async';
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
// #docregion platform_imports
// Import for Android features.
// import 'package:webview_flutter_android/webview_flutter_android.dart';
@zblurx
zblurx / lapsv2_decryptor.py
Last active April 24, 2024 06:42
Simple script to extract local admin password in cleartext with LAPSv2 using impacket
import argparse
import typing
import math
from uuid import UUID
from pyasn1.codec.der import decoder
from pyasn1_modules import rfc5652
from struct import unpack
from cryptography import utils
from cryptography.exceptions import AlreadyFinalized, InvalidKey
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
[
"1185030898148724777",
"956131521733984287",
"956097947727179806",
"1185045871478448242",
"932096380879667253",
"956246550152118374",
"928549000431407164",
"976786710836944936",
"956128945227567145",
@Geczy
Geczy / migrate.sh
Last active April 24, 2024 06:41
Migrate Coolify to a new server
#!/bin/bash
# This script will backup your Coolify instance and move everything to a new server. Docker volumes, Coolify database, and ssh keys
# 1. Script must run on the source server
# 2. Have all the containers running that you want to migrate
# Configuration - Modify as needed
sshKeyPath="$HOME/.ssh/your_private_key" # Key to destination server
destinationHost="server.example.com"
@CanOfColliders
CanOfColliders / split-skymap-into-images.py
Created July 15, 2013 10:08
Simple script to split a cubemap/skymap image produced by blender into 6 separated image files for use in Unity3Ds skybox materials.
#!/usr/bin/env python
# Will split a png cubemap/skymap image produced by blender into 6 separated image files for use in a skybox within unity
# Requires Python Imaging Library > http://www.pythonware.com/products/pil/
# The author takes no responsibility for any damage this script might cause,
# feel free to use, change and or share this script.
# 2013-07, CanOfColliders, m@canofcolliders.com
from PIL import Image