Skip to content

Instantly share code, notes, and snippets.

@rseon
rseon / highlighString.js
Last active September 7, 2020 15:13
Highlights a string in another
/**
* Highlights a string in another.
*
* This methods wrap the portion of ${search} found in ${str} with a ${tag} with class ${className}.
* If ${search} was not found, ${str} is returned
*
* @example highlightString('Hello World !', 'world') // "Hello <span class="highlight">World</span> !"
* @example highlightString('Hello World !', 'foo') // "Hello World !"
* @example highlightString('Hello World !', 'world', 'test', 'div') // "Hello <div class="test">World</div> !"
*
@rseon
rseon / clone.md
Last active April 26, 2021 10:34
Clone a Laravel repository

Clone a Laravel repository

Or anything else from Github.

Retrieve and install the project

git clone https://github.com/me/my-project.git
chown -R www-data:www-data my-project
cd my-project
composer install
@rseon
rseon / Laravel 6.md
Last active February 12, 2020 14:57

Memo installation Laravel 6.2

See previous memo

Awesome app

composer create-project --prefer-dist laravel/laravel projectname
cd projectname
@rseon
rseon / proc_stock.sql
Created December 17, 2019 16:10
MySQL Storred Procedure example
CREATE PROCEDURE `MyProcedure`(
/*IN `in_field_a` INT,
IN `in_field_b` VARCHAR(255)*/
)
BEGIN
/*DECLARE a_variable BOOLEAN DEFAULT TRUE;
DECLARE b_variable DATE DEFAULT NULL;
SET b_variable = NOW();*/
@rseon
rseon / 0_description.md
Last active November 14, 2019 11:01
Webpack / Laravel Mix / Vue

Webpack / Laravel Mix / Vue

First problem was when I wanted to extract vendors in webpack, chunk files where in the public folder and CSS file is empty.

What I have :

  • public/css/app.css (empty file !)
  • public/js/app.js (ok but sooo big)
  • public/js/0.js, public/js/1.js, ... (chunk files)
@rseon
rseon / Laravel + Homestead.md
Created October 30, 2019 10:51
Laravel + Homestead

Laravel + Homestead (Windows 10)

Nom du projet : my_project URL : my.project.dv

Laravel

Dans le répertoire qui accueille nos fichiers de site :

@rseon
rseon / getIp.php
Created June 21, 2019 08:29
How to get client IP address in PHP
<?php
// @link http://itman.in/en/how-to-get-client-ip-address-in-php/
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
@rseon
rseon / Parsedown.php
Created June 14, 2019 07:43
Extends [Parsedown](https://github.com/erusev/parsedown) with checkboxes and (closing) tags replacement.
<?php
use Parsedown as ParsedownBase;
/**
* Extends [Parsedown](https://github.com/erusev/parsedown) with :
* - Replacement of [ ] by checkbox
* - Replacement of tags by other (only closing tags).
* Usage :
* $Parsedown = new Parsedown();
@rseon
rseon / Passgen.php
Last active June 18, 2019 08:35
Random password generator (from Prestashop 1.7.4.3)
<?php
/**
* Random password generator
*
* @param int $length Desired length (optional)
* @param string $flag Output type (NUMERIC, ALPHANUMERIC, NO_NUMERIC, RANDOM)
* @return bool|string Password
*/
function passwdGen($length = 8, $flag = 'ALPHANUMERIC')
{
@rseon
rseon / dump-tables-mysql.sh
Created May 21, 2019 10:04
Dump MySQL table data into separate SQL files for a specified database.
#!/bin/bash
# dump-tables-mysql.sh
# Descr: Dump MySQL table data into separate SQL files for a specified database.
# Usage: Run without args for usage info.
# Author: @Trutane
# Ref: http://stackoverflow.com/q/3669121/138325
# Notes:
# * Script will prompt for password for db access.
# * Output files are compressed and saved in the current working dir, unless DIR is