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
πŸ”₯3
πŸ’ 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
// ==UserScript==
// @name Jira Fast Task Copy Button
// @namespace http://tampermonkey.net/
// @version 2024-05-03
// @description try to take over the world!
// @author You
// @match https://jira.your-company.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=jira.com
// @grant GM_setClipboard
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
const customStyles = `
.jira-fast-copy-btn {
background-color: #0052CC;
color: white;
padding: 4px 7px 4px 7px !important;
border-radius: 9px;
position: unset !important;
margin-left: 6px !important;
cursor: pointer;
}
.jira-fast-copy-btn_copied {
background-color: green !important;
}
.jira-fast-copy-btn_copied:hover {
background-color: green !important;
}
.jira-fast-copy-btn:hover {
background-color: #0052CCAB;
}
`;
GM_addStyle(customStyles);
let addButton = function (buttonsContainer, text, copy) {
let copyButton = document.createElement('li');
copyButton.className = "jira-fast-copy-btn";
copyButton.innerText = text;
buttonsContainer.appendChild(copyButton);
copyButton.addEventListener("click", function (e) {
copy
? GM_setClipboard(copy)
: alert(text + " not found 4 copy!");
copyButton.classList.add("jira-fast-copy-btn_copied");
setTimeout(function () {
copyButton.classList.remove("jira-fast-copy-btn_copied")
}, 500);
})
}
let alreadyExists = false;
const handleNewNode = (mutationsList, observer) => {
mutationsList.forEach(mutation => {
mutation.addedNodes.forEach(node => {
let buttonsContainer = document.querySelector("header#stalker .aui-nav.aui-nav-breadcrumbs");
if (!buttonsContainer || alreadyExists) {
return;
}
alreadyExists = true;
let id = document.getElementsByClassName("issue-link")[0];
if (id) {
id = id.innerText;
}
let name = document.getElementById("summary-val");
if (name) {
name = name.innerText;
}
addButton(
buttonsContainer,
"Copy Key",
id
);
addButton(
buttonsContainer,
"Copy Summary",
name
);
addButton(
buttonsContainer,
"Copy Key & Summary",
`[${id}] ${name}`
);
let link = document.location.protocol + "//" + document.location.hostname + "/browse/" + id;
addButton(
buttonsContainer,
"Copy Link",
link
);
addButton(
buttonsContainer,
"Copy Key & Summary & Link",
`[${id}] ${name}\n${link}`
);
observer.disconnect();
});
});
};
const config = { childList: true, subtree: true };
const observer = new MutationObserver(handleNewNode);
observer.observe(document.body, config);
})();
πŸ“± 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
πŸ–± Alias 4 Execute Command Stack and Return to Working Directory πŸŽ›

alias command-stack='current_dir=$(pwd); cd /var/www/any-dir/; cmd-one; cmd-two; cd "${current_dir}"'


Example:
alias proxy='current_dir=$(pwd); cd /var/www/docker-ports-proxy/; make; cd "${current_dir}"'



#linux #bash #alias #cd #shell #sh #proxy #script
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ–± Get Top 30 Biggest Files πŸŽ›

find / -type f -exec du -h {} + 2>/dev/null | sort -hr | head -n 30


#bigges #ssd #hdd #size #mem #memory #find #du #df #sort #head #shell #ssh #top #file #files #filesystem
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
β›ˆ Always Enable Parameters Inlay Hints πŸŒͺ

#parameters #idea #phpstorm #webstorm #inlay #hints
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ”₯2
🐧 Git Show All Tags πŸ–₯

git --no-pager tag --sort=refname
git --no-pager tag --sort=-refname # For reverse

git --no-pager tag | sort -V

alias git-tag="git --no-pager tag | sort -V"

git tag 1.0.0

git push origin --tags


#git #bash #cvs #tag #tags #history
Please open Telegram to view this post
VIEW IN TELEGRAM
cowsay "Hello World!"

 ______________
< Hello World! >
--------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||

#funny #cowsay
πŸŽ› Find All Root composer.json Files 🐧

find work/dir-with-many-projects/ -iname composer.json | grep -v "vendor"

grep with flag -v exclude line with founded word

#bash #php #composer #vendor #grep #find
Please open Telegram to view this post
VIEW IN TELEGRAM
sudo apt install xcowsay

xcowsay Hello Smart Backend!

#funny #cowsay #xcowsay
😱3
This media is not supported in your browser
VIEW IN TELEGRAM
alias mew=cat

sudo apt install oneko

oneko

#funny #cat #oneko #mew