Skip to content

Instantly share code, notes, and snippets.

View sjardim's full-sized avatar
🏠
Working from home

Sérgio Jardim sjardim

🏠
Working from home
View GitHub Profile
@sjardim
sjardim / update_meilisearch_index_command.php
Created May 31, 2022 18:10
Laravel command to update Meilisearch's index and filterable attributes
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use MeiliSearch\Client;
use function PHPUnit\Framework\throwException;
class UpdateMeilisearchIndex extends Command
{
@sjardim
sjardim / twill-nested-module-urls.md
Created February 1, 2022 15:25 — forked from chrispymm/twill-nested-module-urls.md
[Support nested urls for nested modules] #twill

By default Twill will disply the url of a module item to be {siteurl}/{module}/{slug} e.g. mysite.com/pages/about. With the 'about' section being the editable slug. This is understandable as Twill knows nothing of your frontend routing. However it is likely confusing for editors, as that url presented will not be the final url of the content.

Remove module name form url

This will give us more correct urls e.g. mysite.com/about

// app/Http/Controllers/Admin/PageController

	protected $permalinkBase = '';

Prefill a block editor from a selection of templates

Objectives:

  • Create a new module with a template field
  • Prefill the block editor for new items according to the selected template

Requirements:

<?php
//Blog post: https://www.hashbangcode.com/article/extracting-data-mp3-php
//USAGE:
//Tested ID3v2.2 and v2.4 and on UTF-8 and UTF-16LE encondings
// $file = 'audio.mp3';
@sjardim
sjardim / ProcessWireValetDriver.php
Created February 10, 2021 11:47 — forked from LostKobrakai/ProcessWireValetDriver.php
ProcessWire Valet Driver
<?php
class ProcessWireValetDriver extends BasicValetDriver
{
private $possibleDirectories = [
'', // PW in root, do not remove except you're sure you never use it
'/dist',
'/public'
];
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.com/before/*;
server {
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
@sjardim
sjardim / move_files_into_multiple_folders.py
Last active October 31, 2019 18:42
This Python script will move the files of the current folder into the folder structure according to a defined structure.
import shutil
import os
# This script will move the files of the current folder into the folder structure according to the FoldersMap.
# detect the current working directory
currentFolder = os.getcwd()
filePath = currentFolder
FoldersMap = {
Sub Export4KPowerpoint()
If ActivePresentation.CreateVideoStatus <> ppMediaTaskStatusInProgress Then
ActivePresentation.CreateVideo FileName:=Environ("USERPROFILE") & "\Desktop\export.mp4", _
UseTimingsAndNarrations:=True, _
VertResolution:=2160, _
FramesPerSecond:=30, _
Quality:=100
Else: MsgBox "There is another conversion to video in progress"
End If
End Sub
@sjardim
sjardim / ProcessSendApi.php
Last active May 15, 2018 11:32
A ProcessWire module to handle API call to a Sendy installation.
<?php namespace ProcessWire;
class ProcessSendyAPI extends WireData implements Module, ConfigurableModule
{
public static function getModuleInfo()
{
return array(
'title' => __('Process Sendy API'),
'summary' => __('Handle API calls to a Sendy installation'),
@sjardim
sjardim / settings.json
Created April 24, 2018 03:27
VS Code Settings
// Place your settings in this file to overwrite the default settings
{
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"editor.accessibilitySupport": "off",
"editor.lineHeight": 30,
"files.associations": {
"*.module": "php",
"*.latte": "smarty"
},
"editor.cursorStyle": "line",