Skip to content

Instantly share code, notes, and snippets.

View jonathanlaf's full-sized avatar

Jonathan Lafleur jonathanlaf

View GitHub Profile
containers:
java:
- name: java_backup
ssh: java:2222
passwordFile: /home/jlafleur/minecraft/java/.rcon-cli.yaml
worlds:
- /data/world
extras:
- /data/logs
- /data/mods
@jonathanlaf
jonathanlaf / functions.php
Created March 25, 2021 13:02
Relevanssi search date through content and through published date
// Inspired by : https://www.relevanssi.com/knowledge-base/natural-language-date-queries/?replytocom=264649#respond
add_filter('relevanssi_modify_wp_query', 'rlv_date_query');
function rlv_date_query($query)
{
if (substr($query->query_vars['s'], 0, 10) === "published:") {
// Remove "published:" from search string.
$query->query_vars['s'] = substr($query->query_vars['s'], 10);
// If The query string is a year... (We check that it's an integer between 1900 and current year)
@jonathanlaf
jonathanlaf / ExcelService.php
Created March 19, 2021 16:55
Laravel Excel Service
<?php
namespace App\Services;
use Exception;
use Illuminate\Support\Carbon;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\IReader;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
@jonathanlaf
jonathanlaf / index.js
Last active October 26, 2020 13:29
Get element parent or sibling by id / class name or tag name
/*
* Use case:
* Need to toggle the next row
*
* The first part of this script is for demo purpose. (In order to make the demo work, you need bootstrap.)
*/
// Get all the btns
const informationToggleBtns = document.querySelectorAll('.toggle-info');
@jonathanlaf
jonathanlaf / fix_permission.sh
Last active April 14, 2020 14:59
Fix Wordpress Permission
#!/bin/bash
#
# To download from command line :
# wget https://gist.githubusercontent.com/jonathanlaf/0240b8c401651af742ac826a69125440/raw/822eafea11056f55f5a239f8fa7062a43a05d600/fix_permission.sh
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
@jonathanlaf
jonathanlaf / articulate-storyline3-howto.md
Last active August 27, 2019 16:21
How to disable Next buttons while timeline play. Articulate Storyline 3

How to disable Next button while timeline play. Articulate Storyline 3

Here's my setup to disable Next button while the virtual teacher talk.

Set a global variable

  • In the top right corner of your Triggers panel click on the variable button "Variable button"
  • Add a new variable
    • Name: slidePlaying
  • Type: True/False
@jonathanlaf
jonathanlaf / articulate-free-menu-to-locked.md
Last active June 20, 2019 19:11
How to control menu type in Articulate Storyline 3 (with javascript)

How to control menu type in Articulate Storyline 3 (with javascript)

Lock the menu untill you reach a certain slide

  • On the starting slide:
    • Set the variable introPlayed with a default of false on the starting slide.
    • Add a trigger with the following settings:
      • Action: Execute JavaScript
      • Script: see "Lock the menu"
      • When: Timeline starts
      • Object: make sure your starting slide is selected
@jonathanlaf
jonathanlaf / HowToSlackDark.md
Last active November 2, 2023 17:19
[Dark Slack] How to hack Slack to get a dark theme #slack #css #hack

🔥 How to "Hack" Slack to get a dark theme. 🔥

Slack Dark Theme

❗ Close Slack if it's running ❗

Installing theme

In your favorite text editor, open the following file :

  • Windows C:\Users\\AppData\Local\slack\app-\resources\app.asar.unpacked\src\static\ssb-interop.js
@jonathanlaf
jonathanlaf / benchmark-for-vs-foreach.php
Last active September 26, 2018 19:19
[Benchmark Loops] Benchmark of FOR vs FOREACH loop functions in php #php #benchmark
<?php
$a = array();
for ($i = 0; $i < 100000; $i++) {
$a[] = $i;
}
$start = microtime(true);
foreach ($a as $k => $v) {
$a[$k] = $v + 1;
}
@jonathanlaf
jonathanlaf / convertSameCaracterToSameAscii.php
Last active August 14, 2018 12:53
[Keyboard char to Ascii] Take care of different ASCII Code returned by a single caracter depending on Keyboard layout. #encoding #php #ascii
<?php
/*
* Accept array or string
*/
function convertSameCaracterToSameAscii($string)
{
$tab_chr = array() ;
for($control = 0; $control < 32; $control++) {
if ($control != 9 && $control != 10) {
$tab_chr[]= chr($control) ;