Skip to content

Instantly share code, notes, and snippets.

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

Diego Arcega diegoarcega

🏠
Working from home
View GitHub Profile
@diegoarcega
diegoarcega / yup-object.validation.js
Last active September 17, 2021 13:39
yup object validation
// when you have a checkbox and want to validate that at least one of the options is selected
patientMedicalConditions: yup
.object({
dizziness: yup.bool(),
diabetes: yup.bool(),
neuropathy: yup.bool(),
historyOfStroke: yup.bool(),
arthritis: yup.bool(),
signsOfBoneDeterioration: yup.bool(),
@diegoarcega
diegoarcega / group.js
Created September 9, 2021 16:08
Sort groups in a list view
// sorts therapy groups by name, therapist and topic and adds therapist data to the payload
const EMPTY_ARRAY = [];
export function processGroups(groups = EMPTY_ARRAY, therapists = EMPTY_ARRAY) {
const groupsLength = groups.length;
const therapistsLength = therapists.length;
const groupsWithTherapistData = [];
function defaultGroupSort(groups = []) {
@diegoarcega
diegoarcega / README.md
Created June 1, 2021 12:36 — forked from tannerlinsley/README.md
Replacing Create React App with the Next.js CLI

Replacing Create React App with the Next.js CLI

How dare you make a jab at Create React App!?

Firstly, Create React App is good. But it's a very rigid CLI, primarily designed for projects that require very little to no configuration. This makes it great for beginners and simple projects but unfortunately, this means that it's pretty non-extensible. Despite the involvement from big names and a ton of great devs, it has left me wanting a much better developer experience with a lot more polish when it comes to hot reloading, babel configuration, webpack configuration, etc. It's definitely simple and good, but not amazing.

Now, compare that experience to Next.js which for starters has a much larger team behind it provided by a world-class company (Vercel) who are all financially dedicated to making it the best DX you could imagine to build any React application. Next.js is the 💣-diggity. It has amazing docs, great support, can grow with your requirements into SSR or static site generation, etc.

So why

@diegoarcega
diegoarcega / Object Flatten
Created January 29, 2020 15:38 — forked from penguinboy/Object Flatten
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
@diegoarcega
diegoarcega / gitflow-breakdown.md
Created May 2, 2018 10:42 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@diegoarcega
diegoarcega / .bashrc
Last active April 19, 2019 22:58
git branch with color
https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt
adding this to .bashrc:
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[93m\]\$(parse_git_branch)\[\033[00m\] $ "