Skip to content

Instantly share code, notes, and snippets.

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

Marko Arsić marsicdev

🏠
Working from home
View GitHub Profile
@marsicdev
marsicdev / async-await-mistakes.js
Created November 9, 2022 17:31
Code snippets for TechTalk JS/TS/React mistakes
// Async/await Pitfalls
async getBooksAndAuthor(authorId) {
// const books = await bookModel.fetchAll(); // 3sec
// const author = await authorModel.fetch(authorId); // 3sec
const [books, author] = await Promise.all([
bookModel.fetchAll(), // 3sec
authorModel.fetch(authorId) // 2sec
])
@marsicdev
marsicdev / abort-promise.js
Created October 27, 2022 13:47
Code samples form ReactWeek TechTalk #5 - Advanced JavaScript features you might need https://speakerdeck.com/marsicdev/techtalk-advanced-javascript-concepts-you-might-need
/**********************************************/
/* How to use AbortController with the Fetch API
/**********************************************/
const url = 'https://jsonplaceholder.typicode.com/todos/1'
const abortController1 = new AbortController()
const abortSignal1 = abortController1.signal
const fetchTodo = async () => {
const pathGroups = ['library', 'app', 'components', 'pages']
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'prettier',
'plugin:prettier/recommended',
### Keybase proof
I hereby claim:
* I am marsicdev on github.
* I am marsicdev (https://keybase.io/marsicdev) on keybase.
* I have a public key ASDZ8n0FreFg6cPxV73eTrwabbu5cd5v_AILaammVrZdvgo
To claim this, I am signing this object:
/******************************
* trimStart & trimEnd
******************************/
let message = ' ES2109 meetup '
message.trimRight()
// ' ES2109 meetup'
message.trimLeft()
@marsicdev
marsicdev / htaccess
Created July 14, 2019 22:25
MAINTENANCE-PAGE REDIRECT
# MAINTENANCE-PAGE REDIRECT
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
</IfModule>
@marsicdev
marsicdev / app.js
Last active January 11, 2019 18:01
ToDo MRP demo
var controller = (function (data, ui) {
function init() {
loadSavedData()
setupEventListeners()
}
function loadSavedData() {
// check LC for data (ctrl, data)
// read Data (data)
@marsicdev
marsicdev / .eslintrc
Created March 23, 2018 22:36
My Visual Studio Code workspace settings for CRA
{
"extends": [
"react-app"
],
"rules": {
"semi": [
"error",
"never"
],
"quotes": [
@marsicdev
marsicdev / index.html
Created March 9, 2018 17:16
MRP GitHub sample
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
@marsicdev
marsicdev / movie-form-es6.js
Last active November 2, 2017 21:30
Movie form refactored to ES2015
const dataController = (() => {
const data = {
movies: [],
totalMoviesLength: 0
};
class Movie {
constructor(title, length, genre) {
this.title = title;