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 / 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 / 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.'));