Skip to content

Instantly share code, notes, and snippets.

@egdoc
egdoc / textbox_shortcode.php
Last active July 8, 2024 08:44
Linuxconfig wordpress textbox shortcode
<?php
function linuxconfig_textbox( $atts, $content = null ) {
$defaults = array(
"title" => "This is the box title",
"type" => "warning"
);
$parsed_atts = shortcode_atts( $defaults, $atts );
if ( ! in_array( $parsed_atts['type'], array( "warning", "success", "danger" ) ) ) {
@egdoc
egdoc / gist:753d3c934f5892a32a29de916fbce8b1
Created May 3, 2024 20:38
Set user avatar using dbus
dbus-send --system --print-reply \
--dest=org.freedesktop.Accounts \
/org/freedesktop/Accounts/User1000 \
org.freedesktop.Accounts.User.SetIconFile string:/path/to/image.jpg
@egdoc
egdoc / policies.json
Last active December 8, 2023 06:43
firefox-policy
{
"policies": {
"DisableSetDesktopBackground": true,
"DisableTelemetry": true,
"EnableTrackingProtection": {
"Value": true
},
"NoDefaultBookmarks": true,
"OfferToSaveLogins": false,
"Extensions": {
@egdoc
egdoc / molecule.yml
Created November 14, 2022 10:47
Use Docker to test systemd services with molecule
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: geerlingguy/docker-fedora36-ansible:latest
command: /lib/systemd/systemd
volumes:
@egdoc
egdoc / konami.js
Created April 9, 2022 13:47
Example of Konami code implementation in Javascript
document.addEventListener('DOMContentLoaded', function() {
'use strict';
const konami_code = [ 'ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a'];
let konami_position = 0;
document.addEventListener('keydown', function (event) {
if (konami_code[konami_position] == event.key) {
konami_position += 1;
if (konami_position == konami_code.length) {
#!/bin/bash
# The command specified in a RETURN trap is executed each time
# a shell function or a script executed with the . or source builtins
# finishes executing. By default, the RETURN trap is not inherited:
sayhi() {
echo "Hi!"
}
main() {
@egdoc
egdoc / download_file_requests.py
Last active April 16, 2019 07:48
Python HTTP requests
#!/usr/bin/env python3
import requests
# steam must be True, otherwise the content will be downloaded all at once
with requests.get("https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.7.tar.xz", stream=True) as response:
with open("latest-kernel.tar.xz", "wb") as tarball:
# iter_content method iterates over response content
# the argument is chunk_size
for chunk in response.iter_content(16384):
tarball.write(chunk)
@egdoc
egdoc / lockonsuspend.py
Created February 28, 2019 14:05
Use python and dbus logind API to lock the screen on suspension with i3lock
#!/usr/bin/env python3
# Basic example of how to use i3lock to lock the screen when system goes to sleep
import subprocess
from pydbus import SystemBus
from gi.repository import GLib
def onSuspend(value):
# When suspending or hibernating the system, "value" will be True
if value:
@egdoc
egdoc / disable-plymouth
Created February 16, 2019 11:19
Boot options to disable plymouth
rd.plymouth=0 plymouth.enable=0
@egdoc
egdoc / 99-custom-nic.rules
Created February 12, 2019 11:33
Udev rule to set ethernet speed to 100Mbs for the matched device: it doesn't work at full speed due to a bug
'ACTION=="add", ATTRS{device}=="0x0250", ATTRS{vendor}=="0x197b", RUN+="/usr/sbin/ethtool -s ens5f5 speed 100 duplex full autoneg on"'