Skip to content

Instantly share code, notes, and snippets.

View connorrose's full-sized avatar

Connor Rose Delisle connorrose

  • New York, NY
View GitHub Profile
// Bad Code
const No = () => (
<div>
<DivSoup />
<ForDinner />
</div>
);
const DivSoup = () => (
<div className="heading-1">
@connorrose
connorrose / useEffect-example.js
Created November 9, 2020 02:33
FEM btholt: useEffect hook example (Intermediate React v2)
import React, { useState, useEffect } from "react";
// Count useEffect calls (cumulative)
let ticks = 0;
const EffectComponent = () => {
const [time, setTime] = useState(new Date());
useEffect(() => {
console.log(++ticks); // Log count @ each call
@connorrose
connorrose / github-workflow.md
Last active August 11, 2020 22:20
Github Workflow for Production Team

Initializing the project

  1. Create a personal fork of organization repository.
  2. Clone fork to your local machine.
  3. In the local clone of your personal fork: git remote add upstream https://github.com/oslabs-beta/Catalyst.git

When starting a new feature (locally)

  1. git checkout master -> Make sure you're starting at your local master branch
  2. git pull upstream master -> Pull in any merged changes from organization master
  3. git push origin master -> Update your remote fork with the new master
  4. git checkout -b -> Create a new feature branch and switch into it
@connorrose
connorrose / This-Binding-Examples.js
Last active September 10, 2020 07:00
This Binding of Arrow Functions vs normal Function Expressions in various contexts
// GLOBAL SCOPE
const foo = () => this;
const bar = function() {return this};
const baz = globalThis;
const thud = this;
console.log('globalThis : this in global scope => ', baz === thud); // false
console.log('Arrow this : this in global => ', foo() === thud); // true
console.log('Function this : globalThis => ', bar() === baz); // true
@connorrose
connorrose / rotated-array-search.js
Created July 11, 2020 15:45
Rotated Array Search
const search = function pivotSearch(nums, target) {
// track sub array start & end
let leftIdx = 0;
let rightIdx = nums.length - 1;
while (rightIdx >= leftIdx) {
const midIdx = ((rightIdx + leftIdx) / 2) | 0;
const midNum = nums[midIdx];
if (target === midNum) return midIdx;