Skip to content

Instantly share code, notes, and snippets.

View kiklop74's full-sized avatar

Darko Miletic kiklop74

  • Moodle US
  • Buenos Aires, Argentina
View GitHub Profile
@kiklop74
kiklop74 / ssh-tunnel-windows.md
Last active January 30, 2024 18:09
Create ssh tunnel on Windows

How to create SSH tunnel on Windows 10/11

Install native SSH client

  • Open PowerShell terminal as admin
  • Execute Get-WindowsCapability -Online | ? Name -like 'OpenSSH.Client*'

Create actual tunnel

  • Open PowerShell terminal as regular user
@kiklop74
kiklop74 / delete-large-fs.md
Last active March 14, 2024 13:30
How to safely delete huge directories without overloading IO and CPU on Linux using Ansible

If we know there will be a time we need to delete safely huge amount of files using ansible without killing IO and CPU this is what can be done

    - name: 'delete directory'
      command: 'ionice -c 3 rm -rf /path/to/dir'
      ignore_errors: 'yes'
      async: 18000
      poll: 30

How to properly install PHP extension oci8 on Ubuntu 22.04

# If using x86_64
wget -nv -P /tmp https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linuxx64.zip
wget -nv -P /tmp https://download.oracle.com/otn_software/linux/instantclient/instantclient-sdk-linuxx64.zip

sudo mkdir -pv /opt/oracle
sudo unzip /tmp/instantclient-basic-linuxx64.zip -d /opt/oracle
sudo unzip /tmp/instantclient-sdk-linuxx64.zip -d /opt/oracle
@kiklop74
kiklop74 / install-php-sqlsrv-ubuntu-22.04-all-versions.md
Last active December 27, 2023 23:26
Install sqlsrv for ubuntu

How to properly install PHP extension sqlsrv on Ubuntu 22.04

curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get -q update
sudo ACCEPT_EULA=Y apt-get install -yq msodbcsql18 unixodbc-dev

This assumes use of Ondrej PPA for php installation

@kiklop74
kiklop74 / nodejs-moodle-docker.md
Last active December 13, 2023 18:31
Install nodejs in Moodle docker

Nodejs in Moodle docker

In case when you need to compile and test javascript modules in your Moodle plugin using Moodle docker setup these are the steps to follow:

# Start docker instance
# Enter the docker shell
moodle-docker-compose exec webserver bash -l
# Inside docker shell execute these commands
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
@kiklop74
kiklop74 / fix-alternative-ubuntu.md
Last active December 7, 2023 13:39
Fixing corrupted alternatives symlink on Ubuntu

Corrupted alternatives link

If you ever end up with error message like this:

sudo -- update-alternatives --config composer
update-alternatives: error: cannot stat file '/opt/composer/bin/composer': Not a directory

Do this to fix it:

Filtering files based on content and filename patterns in Ansible

Often we can see in various Ansible scripts following code:

- name: Test something
  shell: "grep -rq sometexttomatch /path/to/somedir/*.myext"
  register: result
  ignore_errors: True
  changed_when: False

Using Behat with Moodle docker setup on Mac M1/M2 machines

To enable correct use of Behat on modern mac computers we need to perform slight adjustments to the yml scripts.

Open file base.yml and locate following part

  selenium:
    image: "selenium/standalone-firefox${MOODLE_DOCKER_SELENIUM_SUFFIX:-}:${MOODLE_DOCKER_BROWSER_TAG}"
#!/usr/bin/env sh
# -*- mode: sh; coding: utf-8; -*-
# vim: set syntax=sh fileencoding=utf-8
# kate: hl Bash;
export DEBIAN_FRONTEND=noninteractive
uid=$(id -u)
if [ "${uid}" != '0' ]; then
echo 'please run as root'
exit 1

Developer hints

To debug properly this plugin using xdebug make sure to install adequate version for your PHP version.

Official moodle docker setup

Install and configure xdebug 3.x

moodle-docker-compose exec webserver pecl install xdebug-<version 3.x>