Skip to content

Instantly share code, notes, and snippets.

View bernhardkaindl's full-sized avatar

Bernhard Kaindl bernhardkaindl

View GitHub Profile
@bernhardkaindl
bernhardkaindl / XML_breaker.py
Created March 14, 2024 02:11 — forked from nicwolff/XML_breaker.py
Python script to break large XML files
import os
import sys
from xml.sax import parse
from xml.sax.saxutils import XMLGenerator
class CycleFile(object):
def __init__(self, filename):
self.basename, self.ext = os.path.splitext(filename)
self.index = 0
@bernhardkaindl
bernhardkaindl / readme.md
Created March 11, 2024 23:26 — forked from jasonkarns/readme.md
Git send-email using Gmail
  1. Configure git.
# ~/.config/git/config
[sendemail]
  confirm = auto
  smtpServer = smtp.gmail.com
  smtpServerPort = 587
  smtpEncryption = tls
  smtpUser = <gmail email address>
@bernhardkaindl
bernhardkaindl / python_source_import.rst
Created December 11, 2023 03:29 — forked from mportesdev/python_source_import.rst
Importing Python source code from a script without the .py extension

Importing Python source code from a script without the .py extension

Generally, to import a python module programatically when you know the file's path, you could do something like this:

import importlib.util
import sys

Assigning Static IP Addresses in WSL2

WSL2 uses Hyper-V for networking. The WSL2 network settings are ephemeral and configured on demand when any WSL2 instance is first started in a Windows session. The configuration is reset on each Windows restart and the IP addresses change each time. The Windows host creates a hidden switch named "WSL" and a network adapter named "WSL" (appears as "vEthernet (WSL)" in the "Network Connections" panel). The Ubuntu instance creates a corresponding network interface named "eth0".

Assigning static IP addresses to the network interfaces on the Windows host or the WSL2 Ubuntu instance enables support for the following scenarios:

@bernhardkaindl
bernhardkaindl / disable_vim_auto_visual_on_mouse.txt
Created October 23, 2023 21:56 — forked from u0d7i/disable_vim_auto_visual_on_mouse.txt
Disable vim automatic visual mode on mouse select
Disable vim automatic visual mode on mouse select
issue: :set mouse-=a
add to ~/.vimrc: set mouse-=a
my ~/.vimrc for preserving global defaults and only changing one option:
source $VIMRUNTIME/defaults.vim
set mouse-=a
@bernhardkaindl
bernhardkaindl / wsl-2-static-ip-address.md
Created October 23, 2023 14:09 — forked from angus-mcritchie/wsl-2-static-ip-address.md
WSL2 Static IP Address (Windows Host Override)

WSL 2 Static IP Address (Windows Host Override)

A crude, but effective solution for hosting local development projects inside WSL 2.

before you start

  • node js is required
  • ⚠️ this script changes your host file - save a copy of your host file before use

Steps

@bernhardkaindl
bernhardkaindl / tutor-lms-change-default-course-base-slug
Created July 16, 2023 20:20 — forked from nayeemch/tutor-lms-change-default-course-base-slug
This code will help you to change base slug `courses` to your preferred slug, replace `example-course-slug` with your own slug.
add_filter('tutor_courses_base_slug', 'change_tutor_course_slug');
/**
* @param $slug
* @return string
*/
if ( ! function_exists('change_tutor_course_slug')){
function change_tutor_course_slug($slug){
$slug = 'example-course-slug';
return $slug;
@bernhardkaindl
bernhardkaindl / course-archive.php
Created July 13, 2023 16:13 — forked from creativeartbd/course-archive.php
Enable filter option on Docent Pro Theme - Currently, On the Docent Pro theme, the filter is not showing after enable the filter option from the tutor settings. Because there is no code available for the filter. So you may replace this file from this location: wp-contents/themes/docent-pro/tutor folder.
<?php
get_header();
get_template_part('lib/sub-header'); ?>
<div class="<?php tutor_container_classes() ?>">
<div class="tutor-archive">
<?php
$course_filter = (bool) tutor_utils()->get_option('course_archive_filter', false);
$supported_filters = tutor_utils()->get_option('supported_course_filters', array());
if ($course_filter && count($supported_filters)) {
@bernhardkaindl
bernhardkaindl / functions.php
Created July 13, 2023 16:12 — forked from creativeartbd/functions.php
Tutor LMS - Redirect user to lesson page directly
/*
On the Enrolled Course page, You can see all the enrolled courses, right? Now, if you click on the title of the course you will be redirected to the course page.
Okay, but if you want to redirect the user to the first lesson of any course then what? Well, use this code:
Go to wp-content/plugins/tutor/templates/dashboard/enrolled-courses.php at line number 39. Here you can see this code:
*/
$custom_url = home_url($post->post_type.'/'.$post->post_name);
@bernhardkaindl
bernhardkaindl / single-course.php
Created July 13, 2023 16:12 — forked from creativeartbd/single-course.php
Tutor LMS - Hide the content as well as the topic list for password protected course. So, go to wp-content/plugins/tutor/templates/single-course.php file and then replace all the code by this gist code.
<?php
/**
* Template for displaying single course
*
* @since v.1.0.0
*
* @author Themeum
* @url https://themeum.com
*
* @package TutorLMS/Templates