Skip to content

Instantly share code, notes, and snippets.

@DavidBuchanan314
DavidBuchanan314 / json_no_dupes.py
Last active August 18, 2024 03:00
How to ensure JSON has no duplicate map keys in Python 3.1+
from typing import List, Tuple, Any
import json
def ensure_no_duplicate_keys(object_pairs: List[Tuple[str, Any]]) -> dict:
value = dict(object_pairs)
if len(value) != len(object_pairs):
raise ValueError("Duplicate JSON map keys")
return value
if __name__ == "__main__":
@aclarknexient
aclarknexient / checkout.py
Created November 23, 2023 18:34
python git checkout using pygit2
import pygit2
def checkout_branch(path, branch_name):
repo = pygit2.Repository(path)
# If the branch isn't already in the local list,
# you have to create a ref for it to point at
# in order to avoid detached head state
if branch_name not in repo.branches.local:
"""
This script converts a properly formatted CSV file to a JSON list.
The CSV must have the `Project ID` in the first column and `OP Amount` in the second column.
The `Project ID` can be found at the end of the voting URL, eg:
https://vote.optimism.io/retropgf/3/application/0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f
https://round3.optimism.io/projects/0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f
`Project ID` = 0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f
@r0x0d
r0x0d / check.py
Last active December 20, 2023 19:41
CLEANUP_MODULES_ON_EXIT_REGEX = re.compile(r"(?i)CleanupModulesOnExit\s*=\s*(yes|true)")
def _is_modules_cleanup_enabled():
"""Verify firewalld modules cleanup config is enabled.
:returns: Whether or not the CleanupModulesOnExit is set to true in
firewalld config.
:rtype: bool
"""
# Return false if the config file does not exist. Either it means that
@evinjaff
evinjaff / addon.xml
Created October 27, 2023 09:23
Random Startup Movie Hack for Arctic Zephyr Kodi Skin
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.autoexec" name="Autoexec Service" version="1.0.0" provider-name="evinjaff">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
</requires>
<extension point="xbmc.service" library="autoexec.py">
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">Automatically run python code when Kodi starts.</summary>
<description lang="en_GB">The Autoexec Service will automatically be run on Kodi startup.</description>
@kazuho
kazuho / quest3-termux.md
Last active February 28, 2025 06:38
Meta Quest 3のlinuxセットアップ

想定読者

  • linuxに関する基本的な知識があるソフトウェアエンジニアもしくはヘビーユーザで、Quest 3のlinuxをGUI環境で使いたい人
  • apkのインストールとか説明しませんが、Quest 3に入れたやつは、アプリ一覧からカテゴリでUntrusted Sourcesみたいなのを選ぶと出てきます
  • termuxの上にlinux distroを載せるのは、遅いのでやりません(下記ベンチマーク参照)。prefixed-rootだろうがシングルユーザだろうがmusl libcだろうが我々なら大丈夫だ!
  • linuxアプリのインストールは特記事項ない限り省略します。勝手にpkg installとかして

ベンチマーク

@rickthackeray
rickthackeray / make-boosters.py
Last active August 9, 2024 13:14
MTG cube booster generator
import random
import sys
import pandas
import numpy
input_file = sys.argv[1]
num_boosters = int(sys.argv[2]) if len(sys.argv) > 2 else 24
@lukassup
lukassup / setup-pw.sh
Last active December 7, 2024 08:57
Low latency for Reaper on PipeWire
#!/bin/sh
# Reaper reports latency of 4ms with this config.
#
# It may also be a good idea to use "Pro Audio" audio profile
#
# $ pactl list short cards
# $ pactl set-card-profile YOUR_CARD_NAME pro-audio
#
@Tekunogosu
Tekunogosu / starfieldcustom.ini
Last active February 13, 2024 13:59
starfieldcustom.ini
[Display]
fDefault1stPersonFOV=90
fDefaultFOV=90
fDefaultWorldFOV=90
fFPWorldFOV=90
fTPWorldFOV=90
;bEnableRaytracing=1
;bUseSkyLighting=1
;set to 0 to disable
fMaxAnisotropy=2
@MiYanni
MiYanni / StarfieldMods.md
Last active February 8, 2024 19:25
StarfieldMods.md