Skip to content

Instantly share code, notes, and snippets.

View awilson28's full-sized avatar

Ayana Wilson awilson28

  • United States
View GitHub Profile

Starting on the master branch:

git checkout -b store (creates new branch called store and switches to it)

Do some work . . .

git add . (stages work for commit, can be more specific than . --- could git add browser and this will add everything in your browser) git commit -m ‘added store model!’ (commits work with message)

If mucho time has passed since you branched from master,

@awilson28
awilson28 / bind.js
Last active February 3, 2016 23:20
function _promiseForAssessmentPastDue (assessment, studentSolution, stepId) {
// use Promise resolve so that we can .spread later on (.spread is not a method on the mongoose object)
return Promise.resolve(mongoose.model('User').findById(studentSolution.user))
.then(_user => {
return Promise.all([
mongoose.model('CohortAssessment').findOne({ assessment: assessment._id, cohort: _user.cohort }),
mongoose.model('Solution').find({ user: studentSolution.user, step: stepId })
])
})
.spread(function(cohortAssessment, gitHubSolution) {
  • STEP 1: npm install js-data and js-data-angular in that order
  • STEP 2: list js-data as a dependency and set default values (DSProvider is the name of the DS object in the config step):
var app = angular.module('nameOfApp', ['js-data'])
  .config(function(DSProvider) {
  
    DSProvider.defaults.basePath = '/api';
    DSProvider.defaults.idAttribute = '_id';
    
 })
/*
write an indexOf method for this particular array
[9, 15, 34, 38, 21, 47, 56, 68, 62, 77, 81, 90]
*/
app.factory('AlbumFactory', function(DS){
var AlbumFactory = DS.defineResource({
basePath: 'api',
name: 'albums',
idAttribute: '_id',
methods: {
raw: function(){
return 'api/albums/'+ this._id + '.image'
}
}
app.factory('AlbumFactory', function(DS){
var AlbumFactory = DS.defineResource({
basePath: 'api',
name: 'albums',
idAttribute: '_id',
// like the mongoose methods object,
//this object allows us to add
// functionality to the prototype
// i.e. create instance methods
methods: {
app.factory('AlbumFactory', function(DS, $state){
// defining a Js-Data resource
var AlbumFactory = DS.defineResource({
basePath: 'api', // what string prepends each uri ?
name: 'albums', // basePath + name = endpoint ('api/albums')
idAttribute: '_id', // where on the object is the primary key stored?
methods: {
go: function(){
// transition to songs state
$state.go('songs', {_id: this._id})
// `eventQueue` is an array that acts as a queue (first-in, first-out)
var eventQueue = [ ];
var event;
// the event loop keeps going "forever"
while (true) {
// perform a "tick"
if (eventQueue.length > 0) {
// get the next event in the queue
event = eventQueue.shift();

STEPS FOR TESTING ASSESSDOT

  1. Set up ngrok server to receive requests at port 80. Throw nrgok uri into msg.config.url in the fork controller in server/api/step/step.controller.js ( on line 64 as of 11/14/15)
  2. log into instructor account and create an assessment (slurping in assessment uri (e.g. https://github.com/FullstackAcademy/express-assessment)
  3. as the instructor, create a cohortAssessment for that assessment
  4. log into account of student that belongs to that cohort
  5. as student, a) fork assessment b) clone assessment c) push assessment to trigger sending of assessment to docker container
client.events.getDataFromPaginatedAPIAsync({
  per_page: // INT -> number of events displayed per page, 
  user: client.user, 
  page: // INT -> page number we're on
})