Skip to content

Instantly share code, notes, and snippets.

View tsongas's full-sized avatar

Chris Tsongas tsongas

  • Vercel
  • Seattle
  • 05:21 (UTC -07:00)
  • LinkedIn in/tsongas
View GitHub Profile
@tsongas
tsongas / index.html
Last active November 2, 2018 01:39
jQuery.submit() example
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form id="target" action="destination.html">
<input type="text" value="Hello there">
@tsongas
tsongas / .eslintrc
Last active October 27, 2018 23:14
VS Code ESLint Config
{
"env": {
"es6": true,
"node": true
},
"plugins": [
"mocha"
],
"parserOptions": {
"sourceType": "module"
We couldn’t find that file to show.
@tsongas
tsongas / redux-devtools-thunk.js
Created March 11, 2017 02:49
How to use Redux DevTools with Redux Thunk
import { createStore, applyMiddleware } from 'redux';
import reduxThunk from 'redux-thunk';
import reducers from './reducers';
const store = createStore(reducers,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
applyMiddleware(reduxThunk));
export function loginUser(employeeId, password) {
return function(dispatch) {
axios.post(`${ROOT_URL}/authenticate`, { employeeId, password })
.then(response => {
dispatch({ type: AUTH_USER });
localStorage.setItem('id', response.data.id);
localStorage.setItem('token', response.data.token);
browserHistory.push('/home');
})
.catch(() => {
@tsongas
tsongas / gist:4ec55db2f93f848b67582e09713ee7c6
Created February 10, 2017 06:00
You don't have to immediately chain a promise, so just use the if/else to set a promise variable, and then set up a chain on that.
Setlist.count({}, (err, count) => {
let promise;
// if db is empty, create a setlist
if (count === 0) {
promise = Setlist.create({
tracks: [req.body.track]
});
} else {
// add track to setlist
promise = Setlist.findOneAndUpdate({},
@tsongas
tsongas / assessment.md
Last active August 22, 2016 06:19
Mentor Hiring - SET Assessment

JavaScript

Don't worry you're definitely not the first person to be confused by this type of problem! Before doing alert(prizes[btnNum]) try alerting just btnNum by itself and see if that gives you a clue as to what's going on.

To solve this problem, remember you can pass the click event to the function that handles it like this:

function(e) {
  // do something
};