Skip to content

Instantly share code, notes, and snippets.

View MohamedLamineAllal's full-sized avatar

Mohamed Lamine Allal MohamedLamineAllal

View GitHub Profile
@MohamedLamineAllal
MohamedLamineAllal / es6importRegexMatch.js
Last active February 2, 2019 01:32
es6 import regex match
//With grouping : (can check and play with at => https://regexr.com/47jkp)
/import\s+?(?:(?:([\w*\s{},]*)\s+from\s+?)|)(?:(?:"(.*?)")|(?:'(.*?)'))[\s]*?(?:;|$|)/g
group 1 : the string between import and from. (if there is) (it will be undefined if not)
group 2 and 3 : the path of the import [only one of the two, the other is undefined)
if group 2: then it mean "" are used
if group 3: then it mean '' are used [i did that so i support same quotation mark check]
//without grouping (https://regexr.com/47jlq)
@MohamedLamineAllal
MohamedLamineAllal / ReactImportInlineSvg.jsx
Created January 31, 2019 21:32
React import svg inline as component
import {ReactComponent as MyIcon} from 'connected.svg'
export default class ConnexionBox extends PureComponent {
render() {
return (
<div>
<MyIcon className="connectedIcon" alt="connected"/>
</div>
);
}
@MohamedLamineAllal
MohamedLamineAllal / ReactImporturlWay.jsx
Created January 31, 2019 21:29
React import svg url way
import myIcon from './icons/connected.svg'
export default class ConnexionBox extends PureComponent {
render() {
return (
<div>
<img src={myIcon} alt="connected" />
</div>
);
}
@MohamedLamineAllal
MohamedLamineAllal / umd-script-boilerplate.js
Created December 19, 2018 23:06 — forked from cferdinandi/umd-script-boilerplate.js
A simple boilerplate for UMD JS modules.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {
@MohamedLamineAllal
MohamedLamineAllal / ISC.md
Created December 17, 2018 00:50 — forked from indexzero/ISC.md
ISC vs. MIT

Copyright (c) 4-digit year, Company or Person's Name

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Source: http://opensource.org/licenses/ISC

@MohamedLamineAllal
MohamedLamineAllal / php_boilerpalte.php
Created December 16, 2018 15:01
PHP boiler plate (Important things that we use often)
<?php
// indexOf equivalent (get pos of a string within another)
int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
// http://php.net/manual/en/function.strpos.php
$pos = strpos($mystring, $findme);
// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
@MohamedLamineAllal
MohamedLamineAllal / laravel_eloquentBoilerPlate.php
Created December 15, 2018 22:39
Laravel eloquent boilerplate (All the useful things)
<?php
// multiple And on where
// ->where([[],[],...])
Model::where([
['companyId', $companyId],
['period_start', $periodStart],
['period_end', $periodEnd]
])

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...
@MohamedLamineAllal
MohamedLamineAllal / jqueryValidation_boilerplate.js
Created November 28, 2018 18:07
Jquery validation bolerplate (with remote, and message overidding, and different examples)
/*
jquery validation support remote verification (return true or false) (you can use that to verify uniqueness for example
*/
$(function() {
$("#form-register").validate({
rules: {
fname: {
required: true
},
@MohamedLamineAllal
MohamedLamineAllal / Laravel_migration_boiler_migrationfile.php
Last active November 28, 2018 10:52
Laravel migrations boilerplate
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePricingPlansTable extends Migration
{
/**
* Run the migrations.