Skip to content

Instantly share code, notes, and snippets.

View floriandejonckheere's full-sized avatar

Florian Dejonckheere floriandejonckheere

View GitHub Profile
@floriandejonckheere
floriandejonckheere / networkmanager_notifications.sh
Created June 15, 2024 18:27
networkmanager_notifications.sh
# Reset "don't show this notification again" on NetworkManager notifications
dconf reset /org/gnome/nm-applet/disable-connected-notifications
# frozen_string_literal: true
class LRUCache
attr_reader :capacity, :cache
def initialize(capacity)
@capacity = capacity
@cache = {}
end
@floriandejonckheere
floriandejonckheere / yaml-keysort.rb
Created May 16, 2022 07:35
Sort YAML files while keeping the comments intact
#!/usr/bin/env ruby
#
# yaml-keysort.rb - Sort YAML files by key while keeping comments intact
#
# Note: script does not parse YAML and copies lines entirely, only keeping track of top-level keys.
# Ensure there is a blank line between each block.
# frozen_string_literal: true
file = ARGV.pop
@floriandejonckheere
floriandejonckheere / resolve.rb
Created January 7, 2022 14:47
Resolve schema migration merge conflicts
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This script automatically resolves merge conflicts in the schema migrations
# part of structure.sql. It sorts, deduplicates and reformats all migration
# entries in the file.
#
# Example:
#
@floriandejonckheere
floriandejonckheere / MIKROTIK.md
Last active September 28, 2021 10:52
MikroTik EDPNET

MikroTik configuration for EDPNET

  1. Connect fiber modem on ether1
  2. Add VLAN on ether1 with id 10 (vlan-edpnet)
  3. Add PPPoE client on vlan-edpnet, user: xxx@EDPNET
  4. Add NAT: out interface = vlan-edpnet, action = masquerade

IPv6

  1. /system package enable ipv6
@floriandejonckheere
floriandejonckheere / README.md
Last active July 20, 2022 16:34
PXE install Windows 10

Install Windows 10 over PXE from Linux

Follow this guide if you want to install Windows over PXE using Arch Linux as a PXE server.

Ensure the PXE target is booting in UEFI mode (without CSM support). Set PCI LAN as first and only boot device, and disable UEFI IPv6 Network Stack (we'll boot over IPv4).

pacman -S dnsmasq wimlib darkhttpd samba
@floriandejonckheere
floriandejonckheere / find_deps.rb
Last active February 1, 2019 15:37
Find cyclical dependencies in Open Webslides' frontend code
#!/usr/bin/env ruby
NODES = []
`grep -r "from 'modules/" app/modules`.split(%r{$}).map(&:strip).each do |line|
next if line.empty?
split = line.split ':'
source = split.first.match(%r{^app/modules/([^/]*)})&.captures&.first
@floriandejonckheere
floriandejonckheere / application_controller.rb
Created May 3, 2017 08:16
Allow embedding of Rails controllers in iframes
# frozen_string_literal: true
class ApplicationController < ActionController::API
after_action :allow_iframe
protected
def allow_iframe
response.headers['X-Frame-Options'] = 'ALLOW-FROM localhost:3000'
end
end
# frozen_string_literal: true
class Handler
attr_accessor :next_handler
def initialize(next_handler = nil)
@next_handler = next_handler
end
def handle(package)
@floriandejonckheere
floriandejonckheere / bumblebee.sh
Created February 3, 2017 10:54
Enable/disable Bumblebee relevant services and modules
#!/bin/sh
if [[ "$1" == "stop" ]]; then
sudo systemctl stop nvidia-persistenced bumblebeed
sudo rmmod nvidia_modeset nvidia
echo OFF | sudo tee /proc/acpi/bbswitch
cat /proc/acpi/bbswitch
xrandr --output VIRTUAL3 --off --output VIRTUAL2 --off --output VIRTUAL1 --off --output VIRTUAL7 --off --output VIRTUAL6 --off --output VIRTUAL5 --off --output VIRTUAL4 --off --output VIRTUAL9 --off --output VIRTUAL8 --off --output LVDS1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output VGA1 --off
else
sudo systemctl start nvidia-persistenced bumblebeed