Skip to content

Instantly share code, notes, and snippets.

const cookies = {
set: (name, value, days) => {
const date = new Date()
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))
const expires = 'expires=' + date.toUTCString()
document.cookie = name + '=' + value + '; ' + expires
},
get: () => {
console.log('get')
}
@jaredreich
jaredreich / timezones.json
Last active December 4, 2023 16:37
JSON Timezone List
[
   {
      "value": -12,
      "text": "(GMT -12:00) Eniwetok, Kwajalein"
   },
   {
      "value": -11,
      "text": "(GMT -11:00) Midway Island, Samoa"
   },
   {
@jaredreich
jaredreich / countries.json
Created October 13, 2016 22:21
JSON Country List
[
{
"value":"AF",
"text":"Afghanistan"
},
{
"value":"AX",
"text":"Åland Islands"
},
{
@jaredreich
jaredreich / get.js
Last active March 28, 2018 23:44
Check and return nested javascript object via key (array support)
const get = (obj, target, fallback) => {
try {
return eval(`obj${target}`)
} catch (e) {
return fallback
}
}
const obj = {
a: {
@jaredreich
jaredreich / .gitconfig
Last active January 19, 2022 21:15
Handy Git Aliases
[alias]
b = branch
bd = branch -D
c = commit -m
co = checkout
cob = checkout -b
p = pull
pune = pull --prune
s = status
undo = reset HEAD^
@jaredreich
jaredreich / uuid-v4.js
Last active March 7, 2017 17:08
Generate an RFC4122 version 4 compliant UUID
const generateUUID = () => (
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
const r = Math.random() * 16 | 0
const v = c === 'x' ? r : (r & 0x3 | 0x8)
return v.toString(16)
})
)
@jaredreich
jaredreich / index.html
Created September 30, 2017 12:16
Text gradient with CSS
<h1>
The quick brown fox jumped over the lazy dog.
</h1>

Keybase proof

I hereby claim:

  • I am jaredreich on github.
  • I am jaredreich (https://keybase.io/jaredreich) on keybase.
  • I have a public key ASCnzRC35EEGKbWFMBYHVcj6t97dtlr8DzS2_Mj7lqc16go

To claim this, I am signing this object:

@jaredreich
jaredreich / client.js
Created February 27, 2018 20:51
iframe scroll to bottom detection (cross browser, including mobile safari)
window.addEventListener('scroll', handleScroll);
window.addEventListener('message', handleMessage);
handleMessage = (event) => {
if (event.data === 'scrolledToBottom') handleScrolledToBottom();
}
handleScroll = () => {
if ((window.innerHeight + window.pageYOffset) >= window.document.body.scrollHeight) {
this.handleScrolledToBottom();
@jaredreich
jaredreich / full_path_macos_finder_title_bar.txt
Last active March 18, 2018 14:06
Show full path in macOS finder title bar
ON:
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true; killall Finder
OFF:
defaults write com.apple.finder _FXShowPosixPathInTitle -bool false; killall Finder