Skip to content

Instantly share code, notes, and snippets.


Mohcin Bounouara MohcinBN

View GitHub Profile
MohcinBN / reading-time.php
Last active November 13, 2022 14:17
Laravel 9 reading time for yuour posts
View reading-time.php
// add this function to your post model;
// reading time
//The average reader reads about 200 words per minute, so I decided to have less to make estimates more accurate
public function postReadingTimeEstimation($averageReadsPerMunite = 180)
$textOfTheBody = $this->body;
$totalWords = str_word_count(strip_tags($textOfTheBody));
$minutes = floor($totalWords / $averageReadsPerMunite);
View LivePreviewPureJavascript.js
/* html and css
<div class="card">
PHP Web Developer
Full Time Job
MohcinBN / EvenNumbersInArray.php
Last active May 18, 2022 17:35
Find Numbers with Even Number of Digits
View EvenNumbersInArray.php
$nums = [6, 12];
function findNumbers($nums) {
// initialise the count
$count = 0;
foreach($nums as $num){
$numLenght = strlen($num);
MohcinBN / csvToXml.php
Created May 12, 2022 18:23
View csvToXml.php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
$csv = [];
if ($_FILES['csv']['error'] == 0) {
$name = $_FILES['csv']['name'];
$ext = strtolower(end(explode('.', $_FILES['csv']['name'])));
MohcinBN / csvToXml.hmtl
Created May 18, 2022 17:35
CSV TO XML using PHP, Ajax
View csvToXml.hmtl
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS -->
<link href="" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>SCV To XML</title>
MohcinBN / Galaxy-5-target.css
Last active May 6, 2021 21:06
Galaxy 5 640x360 resolution target CSS
View Galaxy-5-target.css
@media only screen and (max-width: 640px) and (orientation : landscape) {
//your code here
MohcinBN / promise.js
Created September 25, 2020 11:59
JavaScript promise example
View promise.js
const myPromise = new Promise((resolve, reject) => {
let connection = false;
if (connection) {
resolve('Conection is OK');
} else {
reject('conection is not OK')
MohcinBN / vue-image-slide.js
Created January 6, 2021 14:44
Vue Js Images Slide easy to understand, based on existing example on the net I just Develop and simplify it it a little
View vue-image-slide.js
<!-- HTML -->
<div id="app">
<a @click.prevent="prevSlide()" href="#" id="prev-slide"
><i class="fas fa-chevron-right"></i
<a @click.prevent="nextSlide()" href="#" id="next-slide"
><i class="fas fa-chevron-left"></i
<div class="col-md-12 p-0 slide">
<div v-for="slide in [currentSlider]" :key="">
View text_to_downlable_image.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Text To Downloadable Image</title>
MohcinBN / show-hide-password.html
Last active May 6, 2021 21:04
Vue Js Hide/Show Password
View show-hide-password.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Show/hide Password</title>
<script src=""></script>