Skip to content

Instantly share code, notes, and snippets.

View nympheastudio's full-sized avatar
🏠
store.dispatch('CURRENT_LOCATION', home)

Nymphea Studio nympheastudio

🏠
store.dispatch('CURRENT_LOCATION', home)
View GitHub Profile
@nympheastudio
nympheastudio / recoilWithUseRef.js
Created June 9, 2023 13:42 — forked from jickoo/recoilWithUseRef.js
recoil with useRef
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;
@nympheastudio
nympheastudio / ScreenshotExample expo react native
Created December 9, 2022 15:30
The height, width, and quality options can be adjusted to control the size and quality of the screenshot.
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,
@nympheastudio
nympheastudio / copy_manufacturers_as_categories.php
Created December 8, 2022 09:46
insert new category from each manufacturers (for Prestashop 1.6)
<?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
}
@nympheastudio
nympheastudio / slim-redux.js
Last active October 30, 2022 22:09 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
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])) {
@nympheastudio
nympheastudio / gist:1ae85e4821c593a16cfacc2344ba6a54
Created October 12, 2022 15:55
prestashop get image url or productName url by id product
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);
@nympheastudio
nympheastudio / unzip.php
Created February 2, 2021 10:22
dézipper .zip en PHP
$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 ! ";
}
//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';
});
@nympheastudio
nympheastudio / fullbackup.php
Created August 25, 2018 10:59 — forked from wei/fullbackup.php
CPanel Full Backup Cron Script
<?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 *********
@nympheastudio
nympheastudio / gist:af514cbd917c2e6488f44de5b7100557
Created December 5, 2016 08:16 — forked from PrestaEdit/gist:10270131
PrestaShop | Image upload
$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.'));