Skip to content

Instantly share code, notes, and snippets.

@paul-vd
paul-vd / untrack-git-files.md
Last active February 25, 2021 09:22
This helps untract files previous pushed to repo, and then added to .gitignore

This helps untract files previous pushed to repo, and then added to .gitignore

git rm -r --cached .
git add .
git commit -m "chore: untracked files issue resolved to fix .gitignore"

Here is another example un-tracking files like .env and then removing it from the history

@paul-vd
paul-vd / git-head
Created May 5, 2020 19:56
fatal: The current branch master has multiple upstream branches, refusing to push.
git config remote.origin.push HEAD
@paul-vd
paul-vd / spinner.svg
Last active May 10, 2020 09:02
SVG Spinner
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@paul-vd
paul-vd / arrayBufferToBase64.ts
Created May 16, 2020 20:05
Array Buffer to Base64
function arrayBufferToBase64(buffer:ArrayBuffer) {
let binary = ''
const bytes = new Uint8Array(buffer)
bytes.forEach(b => (binary += String.fromCharCode(b)))
return window.btoa(binary)
}
@paul-vd
paul-vd / markdown.md
Created May 19, 2020 20:04 — forked from adardesign/markdown.md
markdown Template

Banner Rotator

Banner rotator on adorama.com

Overview

Requires: jQuery 1.4 and up.

Syntax

Strong and Emphasize

@paul-vd
paul-vd / with-defaults.ts
Last active May 27, 2020 22:15
Default Props Function Component
import React from 'react'
const withDefaults = <P, DP>(component: React.ComponentType<P>, defaultProps: DP) => {
type Props = Partial<DP> & Omit<P, keyof DP>
component.defaultProps = defaultProps
// @ts-ignore
return component as React.ComponentType<Props>
}
export default withDefaults
import { useState } from "react";
export function useLocalStorage<T>(key: string, initialValue: T): [T, (s: T) => void] {
// State to store our value
// Pass initial state function to useState so logic is only executed once
const [storedValue, setStoredValue] = useState<T>(() => {
try {
// Get from local storage by key
const item = window.localStorage.getItem(key);
// Parse stored json or if none return initialValue

Dev Setup

  1. Homebrew/terminal/bash
  2. OSX Productivity - Window Management/Quick Launcher/Hyperswitch
  3. OSX Settings - Dock/Finder
  4. Web Browser - Extensions - AdBlock, Privacy Badger, OneTab, JSONViewer, Stylus, Vue Devtools, React Devtools
  5. Node.js - nvm
  6. Code Editor - vs code
  7. Code Editor Extensions
  8. Break timer and Flux
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew cask install iterm2
# update iterm2 settings -> colors, keep directory open new shell, keyboard shortcuts
brew install bash # latest version of bash
# set brew bash as default shell
sudo nano /etc/shells
# add /usr/local/bin/bash to the accepted list of shells
chsh -s /usr/local/bin/bash
@paul-vd
paul-vd / test.md
Last active October 27, 2020 16:14
Hello World Markdown

Hello World

This is content converted from Markdown!

Here's a JSON sample:

{
  "foo": "bar"
}