Skip to content

Instantly share code, notes, and snippets.

View mark123jesper's full-sized avatar
🌐
Currently working on Gitlab

Mark Jesper Pillerva mark123jesper

🌐
Currently working on Gitlab
View GitHub Profile
@mark123jesper
mark123jesper / Countries.js
Created April 5, 2022 06:54
JS file for Countries with Country code, currency and currency symbol and even flag emoji.
export const listCountries = () => {
return [
{
name: 'Afghanistan',
code: 'AF',
capital: 'Kabul',
region: 'AS',
currency: {
code: 'AFN',
name: 'Afghan afghani',
@mark123jesper
mark123jesper / kernel.php
Last active March 1, 2022 10:03
[Solution] Session Store not set on request
Add this middleware on the route you are using for your fortify web/api before the throttle and bindings
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
@mark123jesper
mark123jesper / AppServiceProvider.php
Created March 1, 2022 09:57
[Solution] Laravel Fortify - Invalid Signature
if($this->app->environment('production'))
{
\URL::forceScheme('https');
}
@mark123jesper
mark123jesper / App.js
Created October 4, 2021 00:02
Use useReducer with fetch API
import React, { useEffect, useReducer } from 'react';
import axios from 'axios'
import './App.css';
const initialState = {
loading: true,
error: "",
todos: [],
};
const reducer = (state, action) => {
@mark123jesper
mark123jesper / Flexible useReducer Counter.js
Last active March 25, 2022 04:23
Example of simplified and normal use of useReducer
//Using action.payload to have a flexible data
import React, { useReducer } from 'react'
import { Button, ButtonGroup, Badge } from 'reactstrap';
import 'bootstrap/dist/css/bootstrap.min.css';
const initialState = {
counter1: 0,
counter2: 10
}
const reducer = (state, action) => {
@mark123jesper
mark123jesper / ComponentA.js
Created October 3, 2021 10:48
Different ways on how to use traditional Context and useContext Hook in React
import React from 'react'
import ComponentB from './ComponentB'
const ComponentA = () => {
return (
<div>
<div>ComponentA</div>
<ComponentB />
</div>
)
}
@mark123jesper
mark123jesper / ArrayMap.js
Created October 3, 2021 09:58
Map Array in jsx form
{items.map(item => (NEVER FORGET THE DIFF BETWEEN BRACKET AND PARENTHESIS))}
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
npm run dev
@mark123jesper
mark123jesper / FormData.js
Last active October 3, 2021 09:54
Simple Form Data Structure to prevent unnecessary multiple useState.
const [formData, setFormData] = useState({
name: "",
email: "",
etc: ""
});
const onSubmitHandler = (event) => {
e.preventDefault;
setFormData({...formData, [event.target.name]: event.target.value})
};
@mark123jesper
mark123jesper / vue.json
Created September 18, 2021 01:40 — forked from rochabianca/vue.json
Snippet to bring back scaffold on vue on vscode. To use it go to Code>Preferences>User Snippets type vue on the input and paste this code there.
{
"bring back the scaffold to vue files": {
"prefix": "scaffold",
"body": [
"<template>",
" <div>$TM_FILENAME_BASE</div>",
"</template>",
"",
"<script>",
"export default {",