Skip to content

Instantly share code, notes, and snippets.

View tsongas's full-sized avatar

Chris Tsongas tsongas

  • Vercel
  • Seattle
  • 11:33 (UTC -07:00)
  • LinkedIn in/tsongas
View GitHub Profile
@tsongas
tsongas / f1-class-7-links.md
Last active August 29, 2015 14:17
Links for Class 7
var chai = require('chai');
var chaiHttp = require('chai-http');
var server = require('../server.js');
var should = chai.should();
var app = server.app;
var storage = server.storage;
chai.use(chaiHttp);
var Abc = function(aProperty,bProperty){
this.aProperty = aProperty;
this.bProperty = bProperty;
this.init = function(){
// Do things here.
}
this.init();
};
var currentAbc = new Abc(obj,obj);
@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
};
@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({},
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 / 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));