Skip to content

Instantly share code, notes, and snippets.

View drewwyatt's full-sized avatar

Drew Wyatt drewwyatt

View GitHub Profile
@drewwyatt
drewwyatt / header-1.css
Created April 22, 2014 15:20
Responsive CSS
/* user nav
================================================== */
body.login nav.user {
display: none!important;
}
/* hide the login on the login page ;-)*/
nav.user {
float: left;
var albums = [];
flickr.photosets.getList({ user_id: '127723465@N04' }, function(err, result) {
result.photosets.photoset.forEach(function(set){
albums.push({ id: set.id, title: set.title._content });
});
res.render('index', { title: 'Express', result: result, err: err, albums: albums });
});
@drewwyatt
drewwyatt / games.md
Last active November 19, 2016 23:04

Game Recommendations

This is a list of games I recommend checking out, I did my best to include a wide range of styles.

Here are the games I've gone into detail about below. They all have links to BGG where you can get more information, as well as a link to purchase them on Amazon. I believe these all satisfy the party-game-ish criteria (with one exception).

These link to my descriptions on this page (unless you are looking at this on an iPhone, then I think this table of contents doesn't actually work)

import { Prompter, Validators } from './prompt';
const main = async () => {
const inputs = await new Prompter()
.prompt('What is the auction id?', { validator: Validators.required })
.then(p => p.prompt('Start Date?', { validator: Validators.isDate }))
.then(p => p.prompt('End Date?', { validator: Validators.isDate }))
.then(p => p.finish());
console.log(inputs);
/*
[2018-12-17] Challenge #370 [Easy] UPC check digits
The Universal Product Code (UPC-A) is a bar code used in many parts of the world. The bars encode a 12-digit number used to identify a product for sale, for example:
042100005264
The 12th digit (4 in this case) is a redundant check digit, used to catch errors. Using some simple calculations, a scanner can determine, given the first 11 digits, what the check digit must be for a valid code. (Check digits have previously appeared in this subreddit: see Intermediate 30 and Easy 197.) UPC's check digit is calculated as follows (taken from Wikipedia):
1. Sum the digits at odd-numbered positions (1st, 3rd, 5th, ..., 11th). If you use 0-based indexing, this is the even-numbered positions (0th, 2nd, 4th, ... 10th).
2. Multiply the result from step 1 by 3.
3. Take the sum of digits at even-numbered positions (2nd, 4th, 6th, ..., 10th) in the original number, and add this sum to the result from step 2.
╰─$ gitclean
Running 'git fetch'...
Running 'git remote prune origin'...
Running 'git branch -vv'...
Running 'git branch -d RN-423'...
Running 'git branch -d WE-1885-cancel-subscription-reason'...
Running 'git branch -d anna/WE-2304/app-page-refactor'...
Running 'git branch -d chandra/we-2246-ts'...
Running 'git branch -d dw-more-uat'...
const handler = () => alert('🙌');
const MyComponent = () => <button onClick={handler}>🔥</button>;
const el = findDomNode(this);
el.addEventListener("click", handler);
@drewwyatt
drewwyatt / react-dom-comment.ts
Created May 18, 2019 23:31
onClick={wat} snippet
/**
* Summary of `ReactBrowserEventEmitter` event handling:
*
* - Top-level delegation is used to trap most native browser events. This
* may only occur in the main thread and is the responsibility of
* ReactDOMEventListener, which is injected and can therefore support
* pluggable event sources. This is the only work that occurs in the main
* thread.
*
* - We normalize and de-duplicate events to account for browser quirks. This
@drewwyatt
drewwyatt / useNativeEvent.ts
Created May 18, 2019 23:50
onClick={wat} snippet
import { useEffect, createRef } from 'react';
const stopPropagationAndUseHandler = (handler: EventListener): EventListener => e => {
e.stopImmediatePropagation();
handler(e);
}
export const useNativeEvent = (type: string, handler: EventListener) => {
const ref: React.RefObject<any> = createRef();