Skip to content

Instantly share code, notes, and snippets.

View guillefd's full-sized avatar
🤖
Building

Guillermo guillefd

🤖
Building
View GitHub Profile
@guillefd
guillefd / responsive-video-player.css
Created January 24, 2023 10:37
Responsive Video Player - CSS and Markup
/* player CSS responsive 100% width */
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
}
.embed-container iframe,
.embed-container object,
@guillefd
guillefd / clear-messages-script.php
Last active January 17, 2023 12:50
This PHP Script for Moodle that will set as "deleted" all messages for a given user and date.
<?php
/**
* This PHP Script for Moodle that will set as "deleted" all messages for a given user and date.
* It will insert a row in message_user_actions for every meesage to be deleted.
* Messages will stil exist, but won't display in Messages page view.
*/
// get moodle libs
require_once('config.php');
@guillefd
guillefd / autoredirect.js
Last active November 6, 2024 20:15
Automatically redirect the last html page of the SCORM package to the moodle course main page
/**
* This script will automatically redirect the last html page of the SCORM package
* to the moodle course main page. The courseId and wwwroot is read from Moodle JS object "M".
*
* Important: this script will only work with a SCORM package running on a Moodle course.
* The script must be placed on the last HTML page the SCORM displays, for example
* in "Articulate Storyline" it should be the "/scormdriver/goodbye.html" file.
*/
(function() {
@guillefd
guillefd / VS Code setting.json
Last active January 13, 2023 13:19
VScode Workbench Color Customizations preference
"workbench.colorCustomizations": {
"scrollbarSlider.activeBackground": "#fff",
"scrollbarSlider.hoverBackground": "#f19feb",
"scrollbarSlider.background": "#612883",
"sideBar.border": "#ffe600",
"tab.activeBackground": "#612883",
"tab.activeBorder": "#8b1277",
"sideBySideEditor.horizontalBorder": "#ff0000",
"panel.border": "#ffe600",
"editorGroup.border": "#df0ebc"
@guillefd
guillefd / debug-to-file.php
Last active November 28, 2022 12:26
Moodle plugin development > Debug to File
<?php
function debug_log($var, $label = '') {
$labelcontent = $label ? $label.' ' : '';
$content = PHP_EOL
.date('Y-m-d H:i:s').' '
.$labelcontent
.print_r($var, TRUE)
.PHP_EOL;
error_log($content, 3, dirname(__FILE__).'/debug.log');
@guillefd
guillefd / fake-delay.js
Created January 16, 2020 15:32
Fake Delay
/**
* Fake a delay
* simulate a time delay and return promise
*
* @private
* @param {number} [duration=3000]
*/
async function fakeDelay(duration = 3000) {
await new Promise(resolve => setTimeout(resolve, duration));
}
@guillefd
guillefd / import.ts
Created May 17, 2019 21:25
Import JSON in Angular
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import jsonCfg from '../../../data/config.json';
@Injectable()
export class AppCfg {
constructor(private http: HttpClient) {}
load(): Promise<void> {
@guillefd
guillefd / call-observables-after-observable.js
Last active January 29, 2019 13:53
Get a list, perform a fetch on each item and return one array of objects as result
/**
Returns a list of objects
1. get the list of files to fetch
2. fetch each file to get the object
3. return an array of objects
*/
getAll(): Observable<Tutorial[]> {
const list = this.dataSrv.getDataList()
.pipe(
// get list from dataList
<html>
<style>
.item-header {
grid-area: header;
padding: 0px;
}
.item-btn-a {
grid-area: btnA;
padding: 0px;
@guillefd
guillefd / async-await.js
Created April 3, 2018 18:18 — forked from wesbos/async-await.js
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}