Skip to content

Instantly share code, notes, and snippets.

@dorneanu
dorneanu / plugin_architecture.md
Last active May 14, 2024 21:56
Python: Implement basic plugin architecture with Python and importlib

Implementing a basic plugin architecture shouldn't be a complicated task. The solution described here is working but you still have to import every plugin (inheriting from the base class).

This is my solution:

Basic project structure

$ tree
@OleksiyRudenko
OleksiyRudenko / why-newline.md
Last active May 14, 2024 21:55
Why should text files end with a newline?

Why should text files end with a newline?

Reasons:

  • UNIX standard
  • If the last line in a file doesn't end with a newline then addition of next line affects two lines instead of one. This also pollutes diff on multiple files, so reader may wonder what has changed in a line whereas no significant change has occured.

Multiple newlines at the file end are also redundant as well as spaces at the end of line.

@pablotolentino
pablotolentino / Visual Studio 2022 Product Key
Created November 20, 2021 20:41
Visual Studio 2022 Enterprise Product key
Visual Studio 2022
Enterprise :
VHF9H-NXBBB-638P6-6JHCY-88JWH
Professional:
TD244-P4NB7-YQ6XK-Y8MMM-YWV2J
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Clickable Swedish Keyboard Layout</title>
<style>
body {
display: flex;
justify-content: center;
@angryziber
angryziber / React-Svelte.md
Created May 14, 2024 14:49
My React vs Svelte comparison

React vs Svelte

React Svelte
Since 2011 (before ES6) 2016 (after ES6)
Type Library (slower) Compiler (faster)
Reactivity Hooks, runtime Plain variables, compile-time
Virtual DOM (2 DOMs) Yes No
Performance Mostly ok, DOM diffing, easy to screw up Very fast by default
Memory usage High Low
@kepano
kepano / obsidian-web-clipper.js
Last active May 14, 2024 21:45
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@mattisz
mattisz / ipmi-updater.py
Last active May 14, 2024 21:44 — forked from dekimsey/ipmi-updater.py
Supermicro IPMI certificate updater
#!/usr/bin/env python3
# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=python
# This file is part of Supermicro IPMI certificate updater.
# Supermicro IPMI certificate updater is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@cknd
cknd / traceback.py
Last active May 14, 2024 21:44
super verbose python tracebacks
import sys
import traceback
import linecache
def printlocals(frame, truncate=500, truncate__=True):
sep = '.' * 50
msg = ' %s\n' % sep
for name, value in sorted(frame.f_locals.items()):
if hasattr(value, '__repr__'):
try:
@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except:
@frankyxhl
frankyxhl / zoho_send_email.py
Last active May 14, 2024 21:42
Python script to send email by zoho.com's mail service
# Code from best solution in page below:
# https://help.zoho.com/portal/community/topic/zoho-mail-servers-reject-python-smtp-module-communications
import smtplib
from email.mime.text import MIMEText
from email.header import Header
from email.utils import formataddr
# Define to/from
sender = 'sender@example.com'