Skip to content

Instantly share code, notes, and snippets.

View basnijholt's full-sized avatar

Bas Nijholt basnijholt

View GitHub Profile
@Bilka2
Bilka2 / factorio_blueprint_string_edit.py
Created September 16, 2020 09:23
Decode a Factorio blueprint string, change some of it and reencode it
import json
import zlib
import base64
original_bp_string = '0eNp9j80OgjAQhN9lzq0RFNC+ijGGnw1uQhdCi5GQvrstXjx5m9mfb2c3NMNC08ziYTZwO4qDuW1w3Es9pJpfJ4IBe7JQkNomVztHthlYem3r9slCOkdQYOnoDZOFuwKJZ8/05e1mfchiG5rjwH+SwjS6uDxKShCB+nQoFNYoskOR7sQ0LvWmeeyW1vMr0rWNeiB9gslDSrBnNj8vKrxodjs2v2Tn6nytyio7lkUZwgd0Blhx'
bp_json = json.loads(zlib.decompress(base64.b64decode(original_bp_string[1:])).decode('utf8'))
# there is one entity in the blueprint, it's an assembler with a item request for 2 prod-3 modules and no recipe set
# for the fields of the blueprint json see https://wiki.factorio.com/Blueprint_string_format
bp_json['blueprint']['entities'][0]['items'] = {'copper-plate': 200} # overwrites existing item request
@nwf
nwf / sphinx_toctreeish.py
Created July 15, 2020 23:04
Sphinx Toctree workaround
import re
from typing import List
from docutils import nodes
from docutils.nodes import Node
from docutils.statemachine import StringList, ViewList
import sphinx
from sphinx import addnodes
from sphinx.directives.other import TocTree
@kalkih
kalkih / ios-theme.yaml
Created November 17, 2019 17:46
iOS Theme Home Assistant
ios:
background-image: 'center / cover no-repeat url("/local/img/ios-bg.png") fixed'
accent-color: "#FFF"
primary-color: "#FFF"
light-primary-color: '#B6B6C1'
primary-background-color: "#23232E"
secondary-background-color: rgba(25, 25, 25, 0.5)
divider-color: "#FFF"
### Text ###
primary-text-color: "#FFF"
@dlashua
dlashua / other_app.py
Created November 14, 2019 11:39
Example App Service
# Using Events
class OtherApp:
def initialize(self):
self.fire_event('spotify.start', volume=100)
# Using get_app()
class OtherApp:
def initialize(self):
self.get_app('start_spotify').start(volume=100)
@MarvinT
MarvinT / black_code_prettify.json
Last active January 16, 2023 15:41
json you can paste into jupyter notebook's code prettify configuration that makes it use black to reformat your code instead of yapf.
{
"python": {
"library": "import json\ndef black_reformat(cell_text):\n import black\n import re\n cell_text = re.sub('^%', '#%#', cell_text, flags=re.M)\n try:\n reformated_text = black.format_str(cell_text, 88)\n except TypeError:\n reformated_text = black.format_str(cell_text, mode=black.FileMode(line_length=88))\n return re.sub('^#%#', '%', reformated_text, flags=re.M)",
"prefix": "print(json.dumps(black_reformat(u",
"postfix": ")))"
},
"r": {
"library": "library(formatR)\nlibrary(jsonlite)",
"prefix": "cat(toJSON(paste(tidy_source(text=",
"postfix": ", output=FALSE)[['text.tidy']], collapse='\n')))"
@whiskerz007
whiskerz007 / gist:53c6aa5d624154bacbbc54880e1e3b2a
Last active November 10, 2024 02:39
How to setup a community version of Proxmox VE 5.x-6.x
# Disable Commercial Repo
sed -i "s/^deb/\#deb/" /etc/apt/sources.list.d/pve-enterprise.list
apt-get update
# Add PVE Community Repo
echo "deb http://download.proxmox.com/debian/pve $(grep "VERSION=" /etc/os-release | sed -n 's/.*(\(.*\)).*/\1/p') pve-no-subscription" > /etc/apt/sources.list.d/pve-no-enterprise.list
apt-get update
# Remove nag
echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data.status/{s/\!//;s/Active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" > /etc/apt/apt.conf.d/no-nag-script
@BretStateham
BretStateham / cloud-init-azmobyedge-bionic.yaml
Last active February 28, 2024 13:32
Create an Ubuntu 18.04 VM in Azure and provision it with the Azure CLI, Moby and the Azure IoT Edge Runtime using Cloud-Init
#cloud-config
apt_sources:
- source: "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ bionic main"
key: |
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.7 (GNU/Linux)
mQENBFYxWIwBCADAKoZhZlJxGNGWzqV+1OG1xiQeoowKhssGAKvd+buXCGISZJwT
LXZqIcIiLP7pqdcZWtE9bSc7yBY2MalDp9Liu0KekywQ6VVX1T72NPf5Ev6x6DLV
7aVWsCzUAF+eb7DC9fPuFLEdxmOEYoPjzrQ7cCnSV4JQxAqhU4T6OjbvRazGl3ag
@aeantipov
aeantipov / kwant_wsl.md
Last active May 18, 2019 17:31
Kwant WSL installation

Kwant WSL (Linux subsytem for Windows) installation

Prerequisites for installation: Windows 10 (updates after September 2016) and Linux subsystem for windows. Linux subsystem is in fact Ubuntu 14.04 Trusty, so the instructions are similar. One could in fact use ubuntu instructions (via sudo apt-get install python3-numpy or pip3 install numpy), but the performance would be suboptimal. In order to get optimal perfomance, one needs to compile LAPACK libraries and numpy/scipy. Two ways are possible: manual installation and package manager (spack).

Spack installation

This way of installation has not been tested, but should be easier to do. Since we don't need binaries and ubuntu trusty is old, one needs a source package manager.

@luiscape
luiscape / install_packages.sh
Created January 16, 2017 14:36
Install Python dependency packages from requirements.txt using conda.
#
# Original solution via StackOverflow:
# http://stackoverflow.com/questions/35802939/install-only-available-packages-using-conda-install-yes-file-requirements-t
#
#
# Install via `conda` directly.
# This will fail to install all
# dependencies. If one fails,
# all dependencies will fail to install.