Last active
June 25, 2020 03:15
Revisions
-
max8hine revised this gist
Jun 25, 2020 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,4 +6,9 @@ function dumpObject($object) { var_dump($method); echo "<br>"; }; } if( $image ){ print_r($image->getUrl()); print_r($image->extension); die(); } -
max8hine revised this gist
Apr 29, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -144,6 +144,8 @@ export const getCurrentDate = () => { }; }; // replaceUrlSuffixTo('.png')('anything.jpg') => 'anything.png' export const replaceUrlSuffixTo = suffixWithDot => filePath => filePath.replace(/\.[\w]+$/, suffixWithDot) export const isUrlImage = url => { const validImageSuffix = new RegExp(/\.(jpeg|jpg|gif|png|svg)$/, ""); -
max8hine revised this gist
Apr 29, 2020 . 1 changed file with 82 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -73,3 +73,85 @@ export isUrlImage = url => { const validImageSuffix = new RegExp(/\.(jpeg|jpg|gif|png|svg)$/, ""); return url.match(validImageSuffix) !== null } export is/** * A errorHandler function * Handle Axios request error * Handle Javascript Error instance * Handle Javascript TypeError * Handle Any error and return default error message * @param {Object || Any} error * @returns {String} */ export const errorHandler = ( error, message = "An error occurred, please try again later" ) => { if (!error) return message; if (error.response) { // The request was made and the server responded with a status code // that falls out of the range of 2xx console.info(error.response.data); console.info(error.response.status); console.info(error.response.headers); if (error.response.data.error) { if (typeof error.response.data.error === "string") { message = error.response.data.error; } } return message; } if (error.request) { // The request was made but no response was received // `error.request` is an instance of XMLHttpRequest in the browser and an instance of // http.ClientRequest in node.js console.info(error.request); return message; } // Something happened in setting up the request that triggered an Error if (error.config) console.info(error.config); if (error.message) { console.info(error.message); if (typeof error.message === "string") { message = error.message; } } return message; }; /** * A Craft Date generator * @returns {Object} */ export const getCurrentDate = () => { const now = new Date(); let hour = now.getHours(); let minute = now.getMinutes(); let ap = "AM"; if (hour > 11) ap = "PM"; if (hour > 12) hour = hour - 12; if (hour == 0) hour = 12; if (hour < 10) hour = "0" + hour; if (minute < 10) minute = "0" + minute; return { date: new Date().toLocaleDateString('en-GB'), time: `${hour}:${minute} ${ap}`, }; }; export const isUrlImage = url => { const validImageSuffix = new RegExp(/\.(jpeg|jpg|gif|png|svg)$/, ""); return url.match(validImageSuffix) !== null } export const isInputFileImage = file => { const validImageTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml']); const fileType = file['type'] return validImageTypes.includes(fileType) } -
max8hine revised this gist
Apr 29, 2020 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -67,3 +67,9 @@ export const getCurrentDate = () => { time: `${hour}:${minute} ${ap}`, }; }; export isUrlImage = url => { const validImageSuffix = new RegExp(/\.(jpeg|jpg|gif|png|svg)$/, ""); return url.match(validImageSuffix) !== null } -
max8hine revised this gist
Apr 14, 2020 . 1 changed file with 25 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -42,3 +42,28 @@ export const errorHandler = ( } return message; }; /** * A Craft Date generator * @returns {Object} */ export const getCurrentDate = () => { const now = new Date(); let hour = now.getHours(); let minute = now.getMinutes(); let ap = "AM"; if (hour > 11) ap = "PM"; if (hour > 12) hour = hour - 12; if (hour == 0) hour = 12; if (hour < 10) hour = "0" + hour; if (minute < 10) minute = "0" + minute; return { date: new Date().toLocaleDateString('en-GB'), time: `${hour}:${minute} ${ap}`, }; }; -
max8hine revised this gist
Feb 18, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ */ export const errorHandler = ( error, message = "An error occurred, please try again later" ) => { if (!error) return message; if (error.response) { -
max8hine revised this gist
Feb 18, 2020 . 1 changed file with 44 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ /** * A errorHandler function * Handle Axios request error * Handle Javascript Error instance * Handle Javascript TypeError * Handle Any error and return default error message * @param {Object || Any} error * @returns {String} */ export const errorHandler = ( error, message = "Error occur, Please try again" ) => { if (!error) return message; if (error.response) { // The request was made and the server responded with a status code // that falls out of the range of 2xx console.info(error.response.data); console.info(error.response.status); console.info(error.response.headers); if (error.response.data.error) { if (typeof error.response.data.error === "string") { message = error.response.data.error; } } return message; } if (error.request) { // The request was made but no response was received // `error.request` is an instance of XMLHttpRequest in the browser and an instance of // http.ClientRequest in node.js console.info(error.request); return message; } // Something happened in setting up the request that triggered an Error if (error.config) console.info(error.config); if (error.message) { console.info(error.message); if (typeof error.message === "string") { message = error.message; } } return message; }; -
max8hine created this gist
Sep 24, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ function dumpObject($object) { $class_name = get_class($object); $methods = get_class_methods($class_name); foreach($methods as $method) { var_dump($method); echo "<br>"; }; }