Skip to content

Instantly share code, notes, and snippets.

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

Alfonso alfonsodev

🏠
Working from home
View GitHub Profile
@good-idea
good-idea / 0-readme.md
Last active March 29, 2023 21:00
SWR Lazy Hook

A simple hook to create a "lazy request" hook using swr.

! This isn't perfect !

The problem with the example below is that you need to know your variables when you call useLazyRequest. This might not work in all situations, for instance, if your component is getting the variables from state that might change. This could be fixed by putting the call to useLazyRequest within a child component that receives those variables as props.

See the typescript example below.

Not fully tested, I just wrote this on the fly. If you have any suggestions, please add them in a comment!

@vimtaai
vimtaai / markdown-flavors.md
Last active April 19, 2024 23:08
Comparison of features in various Markdown flavors

Comparison of syntax extensions in Markdown flavors

I created a crude comparison of the syntax of the various common Markdown extensions to have a better view on what are the most common extensions and what is the most widely accepted syntax for them. The list of Markdown flavors that I looked at was based on the list found on CommonMark's GitHub Wiki.

Flavor Superscript Subscript Deletion*
Strikethrough
Insertion* Highlight* Footnote Task list Table Abbr Deflist Smart typo TOC Math Math Block Mermaid
GFM
@ygrenzinger
ygrenzinger / CleanArchitecture.md
Last active March 31, 2024 13:57
Summary of Clean Architecture by Robert C. Martin

Summary of book "Clean Architecture" by Robert C. Martin

Uncle Bob, the well known author of Clean Code, is coming back to us with a new book called Clean Architecture which wants to take a larger view on how to create software.

Even if Clean Code is one of the major book around OOP and code design (mainly by presenting the SOLID principles), I was not totally impressed by the book.

Clean Architecture leaves me with the same feeling, even if it's pushing the development world to do better, has some good stories and present robust principles to build software.

The book is build around 34 chapters organised in chapters.

@alfonsodev
alfonsodev / action-creator-vs-reducer.md
Created October 22, 2017 11:13 — forked from kof/action-creator-vs-reducer.md
Action creator vs. reducer

When should you use action creator and when reducer?

Action creator

  • you need to have side effects
  • you need to read from store to decide what to do
  • you need to dispatch more than one action
  • action produced by action creator needs to contain all the data reducer can need to shape the components state

Reducer

  • should not have any side effects
// Retry 5 times with waiting for 2 seconds
function* updateApi(data) {
for(let i = 0; i < 5; i++) {
try {
const apiResponse = yield call(apiRequest, { data });
return apiResponse;
} catch(err) {
if(i < 4) {
yield call(delay, 2000);
}
@zubaer-ahammed
zubaer-ahammed / Reset MySQL Root Password in Mac OS.md
Last active April 4, 2024 10:38
Reset MySQL Root Password in Mac OS

Reset mysql root password in Mac OS:

First Stop MySQL:

  1. Go to: 'System Preferences' >> 'MySQL' and stop MySQL

OR,

  1. sudo /usr/local/mysql/support-files/mysql.server start
  2. sudo /usr/local/mysql/support-files/mysql.server stop
@matthewjberger
matthewjberger / notes.md
Last active March 11, 2024 10:21
How to make an electron app using Create-React-App and Electron with Electron-Builder.
@brendanzab
brendanzab / reactive_systems_bibliography.md
Last active October 10, 2022 06:36
A reading list that I'm collecting while building my Rust ES+CQRS framework: https://github.com/brendanzab/chronicle

Functional, Reactive, and Distributed Systems Bibliography

Books

Mobile Safari's 100% Height Dilemma

Whether you're developing a web application with native-ish UI, or just a simple modal popup overlay that covers the viewport, when it comes to making things work on iDevices in Mobile Safari, you're in for a decent amount of pain and suffering. Making something "100% height" is not as easy as it seems.

This post is a collection of Mobile Safari's gotchas and quirks on that topic, some with solutions and fixes, some without, in good parts pulled from various sources across the internets, to have it all in one place. Things discussed here apply to iOS8, iOS9 and iOS10.

The Disappearing Browser Chrome

Screen real estate on smartphones is limited, so Mobile Safari collapses the browser chrome (address bar and optional tab bar at the top, and tool bar at the bottom) when the user scrolls down. When you want to make something span exactly the height of the viewport, or pin something to the bottom of the screen, this can get tricky because the viewport changes size (or

@slamus
slamus / .babelrc
Last active May 2, 2016 11:13
My react-native Jest configuration
{
"presets": ["react-native"]
}