Skip to content

Instantly share code, notes, and snippets.

View mushfiqweb's full-sized avatar

Mushfiqur Rahman mushfiqweb

View GitHub Profile
// Data fetching hook
import useSWR from 'swr'
const useUser(userId) {
const fetcher = (...args) => fetch(...args).then(res => res.json())
const { data, error } = useSWR(`/api/user/${userId}`, fetcher)
return {
user: data,
error,
import { createMachine, interpret, assign } from 'xstate';
const fetchMachine = createMachine({
id: 'Dog API',
initial: 'idle',
context: {
dog: null
},
states: {
idle: {
const apiReducer = (state = {}, action) => {
switch (action.type) {
case "START_FETCH_USERS":
return {
...state,
users: { success: false, loading: true, error: false, data: [] }
}
case "FETCH_USERS_SUCCESS":
return {
...state,
{
users: [{ id: "1231", username: "Dale" }, { id: "1235", username: "Sarah"}]
}
{
type: "ADD_USER",
payload: { user: { id: "5123", username: "Kyle" } }
}
const userReducer = (state, action) => {
@mushfiqweb
mushfiqweb / settings.json
Created May 3, 2021 15:30
This is my Windows Terminal Settings
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"copyFormatting": "none",
"copyOnSelect": true,
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"initialCols": 170,
"initialRows": 50,
// Add custom keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about keybindings, visit https://aka.ms/terminal-keybindings
module.exports = {
settings: {
react: {
pragma: 'React',
version: '17.0.1',
},
},
env: {
browser: true,
es6: true,
{
"window.zoomLevel": -0.5,
"editor.mouseWheelZoom": true,
"workbench.iconTheme": "eq-material-theme-icons-darker",
// "editor.fontFamily": "'Fira Code'",
// "terminal.integrated.fontFamily": "'Fira Code'",
// "editor.fontFamily": "Victor Mono",
// "terminal.integrated.fontFamily": "Victor Mono",
"editor.fontFamily": "JetBrains Mono",
"terminal.integrated.fontFamily": "JetBrains Mono",
@mushfiqweb
mushfiqweb / copy-paste-handler.js
Last active October 31, 2020 03:05
SunEditor Image copy-paste Handler Example
// Store Items
const [content, setContent] = useState<string>("");
const [dContent, setDContent] = useState<string>("");
// SunEditor with props
<SunEditor
setOptions={{ buttonList: complex_modified }}
setDefaultStyle="height:auto"
onPaste={handlePaste}
appendContents={content}
if (setSearchView === "searchtenant") {
inQuery.push({ Building: { $in: buildingId } });
orQuery.push({
"CompanyTBL.TenantNumber": { $regex: text, $options: "i" }
});
orQuery.push({
TenantName: { $regex: text, $options: "i" }
@mushfiqweb
mushfiqweb / pr_template.txt
Last active July 2, 2020 10:11
This is an example pull request template for Ground Floor codebase
# Task Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
## What is included in this PR
Give a brief of what's have been done
## Jira Issue Link
Put the Jira link of the issue