Skip to content

Instantly share code, notes, and snippets.

Avatar

Jared Reich jaredreich

View GitHub Profile
@jaredreich
jaredreich / timezones.json
Last active Jul 31, 2020
JSON Timezone List
View timezones.json
[
   {
      "value": -12,
      "text": "(GMT -12:00) Eniwetok, Kwajalein"
   },
   {
      "value": -11,
      "text": "(GMT -11:00) Midway Island, Samoa"
   },
   {
View git_cli_reset_password.sh
git config --global credential.helper osxkeychain
@jaredreich
jaredreich / checkWebPSupport.js
Created Feb 20, 2019
Check WebP support browser-side
View checkWebPSupport.js
const supportsWebP = () => new Promise(resolve => {
const webP = new Image();
webP.src = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA='; // 1x1 black pixel
webP.onload = webP.onerror = () => resolve(webP.height === 1);
})
supportsWebP().then(hasWebP => console.log(hasWebP));
@jaredreich
jaredreich / mac_mouse_acceleration.sh
Created Nov 29, 2019
Turn off mac mouse acceleration
View mac_mouse_acceleration.sh
defaults write -g com.apple.mouse.scaling -1
defaults write -g com.apple.trackpad.scaling -1
@jaredreich
jaredreich / classes.js
Last active Sep 17, 2019
pure javascript add class and remove class functions
View classes.js
var els = document.getElementsByClassName('current-class-name');
removeClass(els, 'current-class-name');
addClass(els, 'new-class-name');
var el = document.getElementById('current-class-name');
removeClass([el], 'current-class-name');
addClass([el], 'new-class-name');
function addClass(elements, className) {
for (var i = 0; i < elements.length; i++) {
@jaredreich
jaredreich / withAsyncErrorHandling.js
Created Sep 16, 2019
Scoped component async event error handling in React
View withAsyncErrorHandling.js
const reservedClassMethodNames = {
componentDidCatch: 1,
componentDidMount: 1,
componentDidUpdate: 1,
componentWillMount: 1,
componentWillReceiveProps: 1,
componentWillUnmount: 1,
componentWillUpdate: 1,
constructor: 1,
getDerivedStateFromError: 1,
View git_fetch_fork_upstream.txt
git fetch upstream
git checkout master
git merge upstream/master
git push
@jaredreich
jaredreich / crypto_browser.js
Created Apr 11, 2019
Browser-side JavaScript AES Encryption
View crypto_browser.js
const crypto = require('sjcl')
const iter = 1000
const ks = 256
export const decrypt = (password, encrypted) => crypto.decrypt(password, encrypted)
export const encrypt = (password, text) => crypto.encrypt(password, text, { iter, ks })
@jaredreich
jaredreich / fix.sh
Created Feb 15, 2019
Fix font issue in macOS Mojave
View fix.sh
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
@jaredreich
jaredreich / git_aliases.txt
Last active Feb 8, 2019
Handy Git Aliases
View git_aliases.txt
* TO SET *
git config --global alias.b "branch"
git config --global alias.bd "branch -D"
git config --global alias.c "commit -m"
git config --global alias.co "checkout"
git config --global alias.cob "checkout -b"
git config --global alias.p "pull"
git config --global alias.s "status"
git config --global alias.undo "reset HEAD^"
You can’t perform that action at this time.