Skip to content

Instantly share code, notes, and snippets.

View thedom85's full-sized avatar
🏠
Working from home

thedom85

🏠
Working from home
View GitHub Profile
//https://www.codewars.com/kata/52742f58faf5485cae000b9a/train/javascript
function formatDuration(seconds) {
if(seconds == 0 ) return "now";
t = Number(seconds);
var y = Math.floor(t / (3600*24*365));
var d = y > 0 ? Math.floor(t % (3600*24*365) /(3600*24)) : Math.floor(t / (3600*24));
var h = d > 0 ? Math.floor((t % (3600*24*365)) %(3600*24) /(3600) ) : Math.floor(t / 3600);
@thedom85
thedom85 / Kata_js_generateShape.js
Created August 29, 2022 15:13
Kata js generateShape
//https://www.codewars.com/kata/59a96d71dbe3b06c0200009c/train/javascript
function generateShape(num){
var outcome = "";
for(var i = 0; i < num;i++){
for(var j = 0; j < num;j++){
outcome=outcome+"+";
}
outcome=outcome+"\n";
}
@thedom85
thedom85 / Kata_js_is_Really_NaN.js
Created July 21, 2022 08:05
Kata js is Really NaN.
// https://www.codewars.com/kata/56c24c58e0c0f741d4001aef/train/javascript
const isReallyNaN = (val) => {
return Number.isNaN(val);
};
console.log(isReallyNaN(37), false)
console.log(isReallyNaN('37') , false)
console.log(isReallyNaN(NaN) , true)
console.log(isReallyNaN(undefined) , false)

Laravel log

View Log Laravel Lumen

tail -f -n 450 storage/logs/laravel*.log \
  | grep -i -E \
    "^\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\]|Next [\w\W]+?\:" \
    --color

Php Laravel Queues

Step1 - Crete migration

php artisan queue:table

Step2 - Run Migration

// https://www.codewars.com/kata/576b93db1129fcf2200001e6/train/javascript
function sumArray(array) {
// --- simple output controls
if(!array) return 0 ;
if(array && Object.keys(array).length <=2) return 0;
// -- find the maximum and the minimum
const max = Math.max(...array);
const min = Math.min(...array);
@thedom85
thedom85 / Math_js_combination.js
Created July 13, 2022 08:31
Math js example combination - combineWithRepetitions - combineWithoutRepetitions
/**
* @param {*[]} comboOptions
* @param {number} comboLength
* @return {*[]}
*/
function combineWithRepetitions(comboOptions, comboLength) {
// If the length of the combination is 1 then each element of the original array
// is a combination itself.
if (comboLength === 1) {
// https://www.codewars.com/kata/591e833267cd75cb02000007/train/javascript
checkRange=(a,x,y)=>a.map(v=>i+=x>v==v>y,i=0)|i

Laravel schedule

Step 1 : Configure cron

crontab -e
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

Laravel 9

Info laravel 9 doc

Install

composer create-project laravel/laravel example-app