This file contains 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 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 React from 'react'; | |
import { View, Button, Alert } from 'react-native'; | |
import { takeSnapshotAsync } from 'expo'; | |
class ScreenshotExample extends React.Component { | |
takeScreenshot = async () => { | |
try { | |
const result = await takeSnapshotAsync(this.view, { | |
result: 'file', | |
height: 500, |
This file contains 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 | |
error_reporting(E_ERROR | E_WARNING | E_PARSE); //good (and pretty enough) for most hostings | |
ini_set('display_errors',1); | |
if (!ini_get('safe_mode')) { | |
@set_time_limit(0); //no time limiting for script, doesn't work in safe mode | |
} else { | |
@ini_set('max_execution_time', '0'); // no time limiting for script, works in SAFE mode | |
} |
This file contains 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 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
public function getImgId(){ | |
$id = Tools::getValue('id'); | |
$action = Tools::getValue('action'); | |
if($action=='getImgId'){ | |
$id_product = $id; // set your product ID here | |
$image = Image::getCover($id_product); | |
$product = new Product($id_product, false, Context::getContext()->language->id); |
This file contains 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
$fichier_zip = 'fichier_zip.zip'; | |
$path = pathinfo(realpath($file), PATHINFO_DIRNAME); | |
$zip = new ZipArchive; | |
$res = $zip->open($fichier_zip); | |
if ($res === TRUE) { | |
$zip->extractTo($path); | |
$zip->close(); | |
} else { | |
echo "Erreur lors du dezippage ! "; | |
} |
This file contains 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
//source : https://dev.to/atulcodex/how-to-add-loader-in-the-website-in-a-few-seconds-4k7n | |
let spinnerWrapper = document.querySelector('.spinner-wrapper'); | |
window.addEventListener('load', function(){ | |
spinnerWrapper.style.display= 'none'; | |
}); |
This file contains 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 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.')); |