Skip to content

Instantly share code, notes, and snippets.

View dimaaan21's full-sized avatar

Dmitry dimaaan21

  • Russia, Cheboksary
View GitHub Profile
@dimaaan21
dimaaan21 / use-focus.js
Last active December 7, 2019 19:25
[REACT] useFocus hook (React 16.8 + Functional component)
const useFocus = () => {
const htmlElRef = useRef(null)
const setFocus = () => {htmlElRef.current && htmlElRef.current.focus()}
return [ htmlElRef, setFocus ]
}
const FocusDemo = () => {
const [inputRef, setInputFocus] = useFocus()
@dimaaan21
dimaaan21 / tips.txt
Created November 14, 2019 15:27
[REACT] Change webpack config in project created with 'create-react-app'
3 ways:
1. node_modules -> react-scripts -> scripts
2. npm run eject
3. use 'react-app-rewired'
@dimaaan21
dimaaan21 / script.js
Created September 4, 2019 17:50
Int => String with spaces
let a = "13788656456456456";
alert(a.replace(/(\d{1,3})(?=((\d{3})*([^\d]|$)))/g, " $1 "));
@dimaaan21
dimaaan21 / pagination.txt
Created May 20, 2019 16:25
pdoPage pagination
[[!pdoPage?
&sortby=`{"menuindex":"ASC"}`
&showHidden=`1`
&tpl=`poleznoArticles` <!-- шаблон Π²Ρ‹Π²ΠΎΠ΄Π° элСмСнтов -->
&limit=`9`
&includeContent=`1`
&includeTVs=`polezno_image_list` <!-- TV name: 'polezno_image_list' -->
&processTVs=`1`
&parents=`76`
&hideContainers=`1`
@dimaaan21
dimaaan21 / vardump.txt
Created April 9, 2019 11:52
[PHP] vardump($var)
function vardump($var) {
echo '<pre>';
var_dump($var);
echo '</pre>';
}
@dimaaan21
dimaaan21 / script.js
Created August 15, 2018 20:27
max-height blocks
var mh = 0;
$(".block").each(function () {
var h_block = parseInt($(this).height());
if(h_block > mh) {
mh = h_block;
};
});
$(".block").height(mh);
@dimaaan21
dimaaan21 / function-cleaner
Created August 13, 2018 19:41
Quick function that would convert the $_FILES array to the cleaner array
<?php
function reArrayFiles(&$file_post) {
$file_ary = array();
$file_count = count($file_post['name']);
$file_keys = array_keys($file_post);
for ($i=0; $i<$file_count; $i++) {
foreach ($file_keys as $key) {
<div class="wrapper">
<div class="menu">
<a href="#" class="menu-btn">Menu</a>
<nav>
<a href="#" class="menu-item">Home</a>
<a href="#" class="menu-item">About</a>
<a href="#" class="menu-item">Team</a>
<a href="#" class="menu-item">Contacts</a>
<a href="#" class="menu-item">Portfolio</a>
</nav>
@dimaaan21
dimaaan21 / [Git] merge branches
Created June 19, 2018 16:50
Merging branches with kdiff3
git config --global mergetool.kdiff3.cmd '"C:\Program Files\KDiff3\kdiff3.exe" $BASE $LOCAL $REMOTE -o $MERGED'
git mergetool
@dimaaan21
dimaaan21 / [Git] commit-editor
Created June 19, 2018 16:47
Custom commit-editor
git config --global core.editor "'C:\Program Files (x86)\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
git commit