Skip to content

Instantly share code, notes, and snippets.

View jonathanlaf's full-sized avatar

Jonathan Lafleur jonathanlaf

View GitHub Profile
@jonathanlaf
jonathanlaf / wpex_pagination.php
Last active April 2, 2022 06:27
[wpexplorer's WordPress pagination script enhanced.] #wordpress
/*
* Numbered Pagination
* http://www.wpexplorer.com/pagination-wordpress-theme/
*/
if ( !function_exists( 'wpex_pagination' ) ) {
function wpex_pagination($wpex_query) {
$prev_arrow = is_rtl() ? '→' : '←';
$next_arrow = is_rtl() ? '←' : '→';
/*
@jonathanlaf
jonathanlaf / getClosestLowerValue.php
Last active August 14, 2018 12:54
[Closest value operator] Get closest value (of an array) before a given one #php #operand
<?php
function valueExpected ($analyse, $expect, $strict = false)
{
if ($strict)
{
if ($analyse === $expect)
{
return '<span style="background-color:darkolivegreen; color:darkgrey;">Received : ' .
$analyse .
', Expected : ' .
@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) ;
@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 / 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 / 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 / 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 / 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 / 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 / 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;