This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from 'react'; | |
import { useRecoilState } from 'recoil'; | |
import { someAtom } from './recoilstates/someState'; | |
const yourCustomHook = () => { | |
const [someState, setSomeState] = useRecoilState(someAtom); | |
const latestSomeState = useRef(someState); | |
useEffect(()=> { | |
latestSomeState.current = someState; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mapValues(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
result[key] = fn(obj[key], key); | |
return result; | |
}, {}); | |
} | |
function pick(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
if (fn(obj[key])) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// PHP script to allow periodic cPanel backups automatically, optionally to a remote FTP server. | |
// Cron Job Command: /usr/local/bin/php /home/<cpanel-username>/fullbackup.php | |
// This script contains passwords. It is important to keep access to this file secure (we would ask you to place it in your home directory, not public_html) | |
// You need create 'backups' folder in your home directory ( or any other folder that you would like to store your backups in ). | |
// ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED ********* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$field_name = 'block_img'; | |
$temp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS'); | |
$salt = sha1(microtime()); | |
$type = strtolower(substr(strrchr($_FILES[$field_name]['name'], '.'), 1)); | |
if ($error = ImageManager::validateUpload($_FILES[$field_name])) | |
$this->_html .= $this->displayError($error); | |
elseif (!$temp_name || !move_uploaded_file($_FILES[$field_name]['tmp_name'], $temp_name)) | |
$this->_html .= $this->displayError($this->l('An error occurred during the image upload')); | |
elseif (!ImageManager::resize($temp_name, dirname(__FILE__).'/img/'.$salt.'.'.$type)) | |
$this->_html .= $this->displayError($this->l('An error occurred during the image upload.')); |