Skip to content

Instantly share code, notes, and snippets.

View bigfoot31's full-sized avatar
🏠
Working from home

Probhonjon Baruah bigfoot31

🏠
Working from home
  • TikTok
  • Singapore
View GitHub Profile
function useMergeState(initialState) {
const [state, setState] = useState(initialState);
// use useRef to improve functionality when calling the setState asynchronously
const stateRef = useRef(state);
function setRefState(newState) {
stateRef.current = newState;
return setState(newState);
}
@RobertAKARobin
RobertAKARobin / python.md
Last active March 8, 2026 07:19
Python Is Not A Great Programming Language
@saqueib
saqueib / errorHandler.js
Last active February 18, 2026 14:54
Global error handling using axios interceptor for http calls http://www.qcode.in/api-error-handling-in-vue-with-axios
import axios from 'axios'
import toast from './toast'
function errorResponseHandler(error) {
// check for errorHandle config
if( error.config.hasOwnProperty('errorHandle') && error.config.errorHandle === false ) {
return Promise.reject(error);
}
// if has response show the error
@logrusorgru
logrusorgru / notf.md
Last active October 3, 2023 01:56
golang functional options problems
@fgilio
fgilio / axios-catch-error.js
Last active February 11, 2026 16:18
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success πŸŽ‰
console.log(response);
} catch (error) {
// Error 😨
@tpae
tpae / Trie.js
Created November 20, 2016 23:49
Trie.js - super simple JavaScript implementation
// Trie.js - super simple JS implementation
// https://en.wikipedia.org/wiki/Trie
// -----------------------------------------
// we start with the TrieNode
function TrieNode(key) {
// the "key" value will be the character in sequence
this.key = key;