Skip to content

Instantly share code, notes, and snippets.

View stronk7's full-sized avatar

Eloy Lafuente stronk7

View GitHub Profile
@stronk7
stronk7 / gist:0c30de590621fc95f70405c2aefe9e59
Created June 26, 2020 15:53
Why on hell icon_system_standard doesn't extend icon_system?
diff --git a/lib/classes/output/icon_system_standard.php b/lib/classes/output/icon_system_standard.php
index 8119a2d6812..c9a2f77e18d 100644
--- a/lib/classes/output/icon_system_standard.php
+++ b/lib/classes/output/icon_system_standard.php
@@ -38,7 +38,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2016 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class icon_system_standard {
+class icon_system_standard extends icon_system {
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
PortSystem 1.0
PortGroup php 1.1
name php-sqlsrv
version 5.6.1
revision 1
categories-append databases
platforms darwin
@stronk7
stronk7 / gist:c19466f7f43faf532d719670a94b7dfb
Created March 27, 2019 09:53
With phpunit 7.x assertEquals(string, string) comparisons now being strict (===), we need to keep them lazy (coz DB returns strings)
Reference: https://github.com/sebastianbergmann/phpunit/issues/3185
stronk7@~/git_moodle/moodle (phpunit70 *$%)$ git diff mod/quiz
diff --git a/mod/quiz/tests/attempt_walkthrough_from_csv_test.php b/mod/quiz/tests/attempt_walkthrough_from_csv_test.php
index 3556793f612..029dbd2ffb1 100644
--- a/mod/quiz/tests/attempt_walkthrough_from_csv_test.php
+++ b/mod/quiz/tests/attempt_walkthrough_from_csv_test.php
@@ -338,7 +338,7 @@ class mod_quiz_attempt_walkthrough_from_csv_testcase extends advanced_testcase {
$this->assertEquals((bool)$value, $attemptobj->is_finished());
break;
/usr/local/bin/salt-cron.sh:
file.managed:
- user: root
- group: root
- source: salt://system/cron/salt-cron.sh
- mode: 755
/usr/bin/chronic /usr/local/bin/salt-cron.sh | /usr/bib/logger -t salt-cron:
cron.present:
- identifier: SALT
@stronk7
stronk7 / Dockerfile
Created April 10, 2017 07:39
A very simple docker image to use unoconv easily
FROM ubuntu:xenial
RUN \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y unoconv && \
apt-get clean && \
rm -rf /var/lib/apt/lists/
# Get latest unoconv script and hack it to use python3.
# (it fixes an issue about unoconv listener failing first time with libreoffice).
@stronk7
stronk7 / hide and lock grade items example
Last active September 9, 2016 09:07
hide and lock grade items example
diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php
index 18e7c16..a246696 100644
--- a/grade/report/grader/lib.php
+++ b/grade/report/grader/lib.php
@@ -838,6 +838,12 @@ class grade_report_grader extends grade_report {
}
} else {
// Element is a grade_item
+ if ($element['object']->itemname == 'One database') {
+ $element['object']->itemname = 'Deletion in progress';
#!/bin/bash
# Find uses of deleted strings for a given commit within codebase.
# May lead to false positives but easily detectable in any case.
#
# Usage: within a git repo: verify_deprecated_string_uses.sh <commit>. Look for ERROR @ output or exit code.
commit=${1:-HEAD}
status=0
pushd "$(git rev-parse --show-toplevel)" > /dev/null
echo "Checking commit ${commit}"
while read -r line; do
#!/bin/bash
while read -r line; do
echo Processing: $line
if [[ ${line} =~ ^\"MDL-[0-9]*\",\"(.*)\" ]]; then
versions=${BASH_REMATCH[1]}
echo Versions: ${versions}
IFS=',' read -ra versionsarr <<< "$versions"
for version in "${versionsarr[@]}"; do
echo $version
@stronk7
stronk7 / pre-push
Last active December 20, 2020 23:18
pre-push hook to avoid Moodle upstream branches to perform travis/github actions builds all the time
#!/bin/bash
# pre-push hook to enable/disable travis and github actions push builds
# based on the nature of the pushed branches.
# - upstream and deleted ones won't be built.
# - development ones will be built.
# Requires travis (client) gem binary installed.
# Requires gh (client) binary installed.
# Useful for people wanting to keep their upstream branches updated,
# and not causing them to perform travis/github actions builds all the time, like me :-)
IFS=' '
@stronk7
stronk7 / dommagic.php
Created April 8, 2015 00:06
Fix broken HTML using DOM hidden superpowers...
<?php
$brokenhtml = '<p>this is broken</p>because i want to </div></div></div><script><script type="text/javascript"><!--';
echo fixhtmlplz($brokenhtml) . "\n\n";
$brokenhtml = '<b>because <i>I can leave <p>everything <div> unclosed
using many <span> lines and <ul> more yet <li> lists
<li> more and
<li> more';
echo fixhtmlplz($brokenhtml) . "\n\n";