Skip to content

Instantly share code, notes, and snippets.

View slykar's full-sized avatar

Sylwester Kardziejonek slykar

View GitHub Profile
@slykar
slykar / polymorphic_tree.py
Last active December 21, 2023 01:26
Combining django-treebeard Materialized Path tree with django-model-utils InheritanceManager #django
from model_utils.managers import InheritanceManagerMixin, InheritanceQuerySetMixin
from treebeard.mp_tree import MP_NodeManager, MP_NodeQuerySet, MP_Node
class PolymorphicTreeQuerySet(InheritanceQuerySetMixin, MP_NodeQuerySet):
"""QuerySet combining functionality of polymorphic up-casting with Materialized Path tree structure"""
class PolymorphicTreeManager(InheritanceManagerMixin, MP_NodeManager):
_queryset_class = PolymorphicTreeQuerySet
@slykar
slykar / django_related_utils.py
Last active July 25, 2018 10:03
Check if related field is loaded when evaluating select_related queryset
@slykar
slykar / fix-grub.md
Last active December 9, 2018 19:55
Fix GRUB

👉Boot linux from USB stick in live mode.


In case your computer has UEFI BIOS execute these commands:

sudo mount /dev/sdXXX /mnt
sudo mount /dev/sdXX /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
@slykar
slykar / vee-validate-buefy-field-type.ts
Created August 9, 2019 12:42
How to specify Buefy field type more easily when doing a form validation
/**
* Returns an object with definition of <b-field :type> for Buefy.
*
* Instead of setting the field type like this:
*
* <b-field :type="{ 'is-danger': errors.has('field_name') }"></b-field>
*
* You can now use it like this:
*
* get fieldTypes() {
// do something 10 times
'.'.repeat(10).split('').forEach(dot => doSomething());
// add 7 more `{}` to `rows`
const rows = [{}, {}];
Array(7).fill({}).map(o => rows.push({}))
// See https://pl.wikipedia.org/wiki/PESEL#Data_urodzenia
// See https://en.wikipedia.org/wiki/PESEL#Birthdates
const CENTURY_MAP: {[k: number]: number} = {
0: 1900,
1: 2000,
2: 2100,
3: 2200,
4: 1800,
};
rancher:
network:
interfaces:
eth0:
address: 192.168.0.100/24
gateway: 192.168.0.1
dns:
nameservers:
- 8.8.8.8
- 8.8.4.4
@slykar
slykar / dell-idrac6-ipmitool-fan-controll.md
Last active March 14, 2024 02:44
Fan control IPMI commands for Dell T610

Dell Fan Control Commands

print temps and fans rpms

ipmitool -I lanplus -H <iDRAC-IP> -U <iDRAC-USER> -P <iDRAC-PASSWORD> sensor reading "Ambient Temp" "FAN 1 RPM" "FAN 2 RPM" "FAN 3 RPM"

print fan info

@slykar
slykar / docker-compose-hackintosh.md
Last active April 25, 2024 15:37
Docker and Docker Compose on AMD OSX Hackintosh via Docker Machine

Introduction

Docker.app will complain about incompatible processor, so we will use Docker Machine.

Instalation

Download Docker for Mac (Docker.app). It contains some binaries that are necessary.

brew install virtualbox docker-machine
@slykar
slykar / OSX Secure Disk Wipe.md
Created December 18, 2019 16:37 — forked from joeblau/OSX Secure Disk Wipe.md
Securely erase an external disk using dd on OSX

Securely erase an external disk using dd on OSX

  1. Plug in your SD card, HDD, or other block device and then use the following command to see which /dev/diskN node it's located on:
diskutil list
  1. Unmount the disk where “N� is the number of the disk taken from the above command: