Smart 🧠 Fullstack
45 subscribers
168 photos
11 videos
13 files
153 links
About channel: everyday developer hints.

for (💲Coders as 💲Student):
echo("Hello 💲Student->name");
endfor;

Author: @BakirovRoman
Download Telegram
🖥 Install Node Version Manager 🎛

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc
nvm i node


Alternative:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

nvm install 20.16.0


Check Current NodeJS Versions

#js #javascript #nvm #npm #node
Please open Telegram to view this post
VIEW IN TELEGRAM
JavaScript create alias for any function 🖥

if (!String.prototype.contains) {
// Provide an alias to 'includes' for older browsers
String.prototype.contains = function(search) {
return this.includes(search);
};
}

// Test the polyfilled 'contains' method
const str = "Hello, World!";
console.log(str.contains("Hello")); // Outputs: true
console.log(str.contains("JavaScript")); // Outputs: false


#js #javascript #includes #contains #alias #frontend
Please open Telegram to view this post
VIEW IN TELEGRAM
🤣1
🐒 Tampermonkey Add Fast Copy Button 🖥

// ==UserScript==
// @name Click to Copy
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Click an element to copy its content to clipboard
// @match https://example.com/* // Replace with the URL of the webpage
// @grant GM_setClipboard
// ==/UserScript==

(function() {
'use strict';

// Add a click event listener to the element you want to copy
document.querySelector('your_element_selector').addEventListener('click', function() {
const contentToCopy = document.querySelector('your_element_selector').innerText; // Replace with the selector for the element
GM_setClipboard(contentToCopy);
alert('Content copied to clipboard: ' + contentToCopy);
});
})();

#tampermonkey #tamper #monkey #copy #js #javascript #frontend #clipboard
Please open Telegram to view this post
VIEW IN TELEGRAM
📱 Jira & Tampermonkey | Add Fast Copy Buttons 🐒

Replace your-company to your company domain.

Get Code

#jira #js #javascript #tamper #monkey #tampermonkey #frontend
Please open Telegram to view this post
VIEW IN TELEGRAM
📱 Remove All Videos From Youtube Watch Later Playlist 🖥

For english interface

For Russian interface:
setInterval(function () {
video = document.getElementsByTagName('ytd-playlist-video-renderer')[0];

video.querySelector('#primary button[aria-label="Меню действий"]').click();

var things = document.evaluate(
'//span[contains(text(),"Удалить из плейлиста")]',
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);

for (var i = 0; i < things.snapshotLength; i++) {
things.snapshotItem(i).click();
}
}, 500);


#google #youtube #watch #later #js #javascript #frontend #script
Please open Telegram to view this post
VIEW IN TELEGRAM
PHP Script 4 Convert JSON String to PHP Array as Code 🖥

<?php

/**
* Converts a JSON string to PHP array code using the new square bracket syntax with proper indentation
*
* @param string $jsonString JSON string to convert
* @return string PHP code representing the array
*/
function jsonToPhpArrayCodeNewSyntax($jsonString) {
// Decode the JSON string to a PHP array
$array = json_decode($jsonString, true);

// Check for decoding errors
if (json_last_error() !== JSON_ERROR_NONE) {
return 'Error decoding JSON: ' . json_last_error_msg();
}

// Convert the array to PHP code with square bracket syntax
return '$data = ' . arrayToPhpCode($array) . ';';
}

/**
* Recursively converts an array to PHP code using square bracket syntax with proper indentation
*
* @param mixed $array The array to convert
* @param int $indentLevel Current level of indentation
* @return string PHP code representing the array
*/
function arrayToPhpCode($array, $indentLevel = 0) {
if (!is_array($array)) {
return var_export($array, true);
}

$code = "[\n";
$indentation = str_repeat(' ', $indentLevel + 1);
foreach ($array as $key => $value) {
$code .= $indentation;
$code .= is_int($key) ? '' : var_export($key, true) . ' => ';
$code .= arrayToPhpCode($value, $indentLevel + 1) . ",\n";
}
$code .= str_repeat(' ', $indentLevel) . "]";

return $code;
}

$jsonString = <<<JSON
{
"name": "Roman",
"age": 27,
"city": "Omsk",
"address": {
"street": "Lenina",
"number": 26
}
}
JSON;

echo jsonToPhpArrayCodeNewSyntax($jsonString) . PHP_EOL;


Input:
{
"name": "Roman",
"age": 27,
"city": "Omsk",
"address": {
"street": "Lenina",
"number": 26
}
}


Output:
$data = [
'name' => 'Roman',
'age' => 27,
'city' => 'Omsk',
'address' => [
'street' => 'Lenina',
'number' => 26,
],
];


#php #js #json #javascript #converter #gpt
Please open Telegram to view this post
VIEW IN TELEGRAM
🌪 JS Max Int 📱

Number.MAX_SAFE_INTEGER; // 9_007_199_254_740_991


#js #max #int #javascript
Please open Telegram to view this post
VIEW IN TELEGRAM