Skip to content

Instantly share code, notes, and snippets.

View donedgardo's full-sized avatar

Edgardo Carreras donedgardo

View GitHub Profile
@donedgardo
donedgardo / loopsQuiz.md
Last active February 7, 2017 22:20
Intro JS Quiz #2

Intro to JS Quiz #2

Loops and functions

1.Given the following array, what is the value of test:

var school = [
  ['David', 'Yamil', 'Edgardo'],
  ['Mari', 'Jan', 'Luis', 'Nelson']
];
var test = school[1][2];
@donedgardo
donedgardo / Next_vs_Meteor.js
Created February 8, 2017 19:32
NExt vs Meteor Article
import cowsay from 'cowsay-browser'
export default () => (
<pre>{ cowsay.say({ text: 'hi there!' }) }</pre>
)
@donedgardo
donedgardo / Next_vs_Meteor2.js
Created February 8, 2017 19:33
Next vs Meteor Article
// pages/index.js
import Link from 'next/link'
export default () => (
<div>Click <Link href="/about"><a>here</a></Link> to read more</div>
)
// pages/about.js
export default () => (
<p>Welcome to About!</p>
)
@donedgardo
donedgardo / es6.js
Last active February 8, 2017 19:43
ES 6 Article
`# Our Schema allows these mutations
type Mutation {
# Update Food Truck Image
updateFoodTruckImage(foodTruckId: ID!, image:String ): FoodTruck
# Update Food Truck Logo
updateFoodTruckLogo(foodTruckId: ID!, logo:String ): FoodTruck
# Update Food Truck Name
updateFoodTruckName(foodTruckId: ID!, name:String ): FoodTruck
...
... and so on with each field! (I'm too lazy to keep doing this ;)
@donedgardo
donedgardo / es6_2.js
Created February 8, 2017 19:43
ES 6 article
`# Our Schema allows these mutations
type Mutation {
# Update Food Truck (omg only in one mutation?!) :p
updateFoodTruck(input: FoodTruckUpdateInput!): FoodTruck
}
# Defines the type of the input
input FoodTruckUpdateInput {
# Id of foodtruck to update
foodTruckId: ID!
# Photo of FoodTruck
@donedgardo
donedgardo / es6_3.js
Created February 8, 2017 19:45
ES6 Article
import mongoose, { Schema } from 'mongoose';
export const FoodTruckSchema = new Schema({
image: {
type: String,
},
logo: {
type: String,
},
name: {
type: String,
@donedgardo
donedgardo / es6_4.js
Created February 8, 2017 19:46
ES6 Article
// ...
FoodTruckSchema.statics.updateFoodTruck = updateFoodTruck;
function updateFoodTruck(input, currentUser) {
return new Promise((resolve, reject) => {
// Code Here
});
}
@donedgardo
donedgardo / es6_5.js
Created February 8, 2017 19:46
ES6 Article
// This is bad
function updateFoodTruck(input, currentUser) {
return new Promise((resolve, reject) => {
// Code Here
let foodTruckId = input.foodTruckId;
let image = input.image;
... and so on :(
});
}
@donedgardo
donedgardo / es6_6.js
Created February 8, 2017 19:47
ES6 Article
// This is Good
function updateFoodTruck({ foodTruckId, image, logo, name, takingOrders, available, location }, currentUser) {
return new Promise((resolve, reject) => {
// Code Here
});
}
@donedgardo
donedgardo / es6_7.js
Created February 8, 2017 19:48
ES6 Article
FoodTrucks.updateFoodTruck({ name: 'Updated FoodTruck Name', foodTruckId: '1234' });