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 January 13, 2023 13:26
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 / form.component.html
Last active December 8, 2022 12:32
Angular Form Validator: Password Strength with upper, lower and number
<form [formGroup]="form">
<input type="password"
formControlName="password">
<p class="help is-danger"
*ngIf="form.get('password').hasError('strong')">
Must have at least one number, one lowercase and one uppercase letter.</p>
</form>
@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 / form-validation-pattern.component.ts
Created January 27, 2018 16:21
Angular Form Validator Pattern: only letters and numbers
import { Component } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'form',
templateUrl: './form.component.html',
styleUrls: ['./form.component.scss']
})
export class Form {
@guillefd
guillefd / element.component.ts
Created February 7, 2018 22:09
Angular, get HTML Element by ID
import { Component, OnInit, EventEmitter, Output, ElementRef, ViewChild } from '@angular/core';
@Component({
selector: 'form-place',
template: `<div #gmap>You got me!</div>`,
styleUrls: ['./form-place.component.scss']
})
export class elementComponent implements OnInit {
@ViewChild("gmap", {read: ElementRef}) gmap: ElementRef;
@guillefd
guillefd / autocomplete.component.ts
Last active July 3, 2020 15:15
Angular, get places/address autocomplete predictions with Google Maps Place API
import { Component } from '@angular/core';
import { FormGroup, FormBuilder } from '@angular/forms';
import { } from '@types/googlemaps';
@Component({
selector: 'autocomplete',
template: `
<input class="input"
type="text"
[(ngModel)]="autocompleteInput"
@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));
}