Skip to content

Instantly share code, notes, and snippets.

View courtneyphillips's full-sized avatar

Courtney Phillips courtneyphillips

  • Datadog
  • Portland, Oregon
View GitHub Profile
@courtneyphillips
courtneyphillips / Child Component
Last active September 13, 2017 17:54
peanut butter jellyyyyy
class PeanutButterJelly extends React.Component {
constructor(props){
super(props);
this.state = {
dummyStateToTriggerUpdate: []
};
this.addToDummyState = this.addToDummyState.bind(this);
setTimeout(() =>
this.addToDummyState(),
https://github.com/webpack/webpack-dev-server/issues/100#issuecomment-283343053
https://github.com/gaearon/react-hot-loader/issues/515
{
"name": "online-store",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
"test": "ng test",
var sheet = SpreadsheetApp.getActiveSheet(),
rows = sheet.getDataRange(),
numRows = rows.getNumRows(),
values = rows.getValues(),
re = ' at',
// Depending on layout and format of spreadsheet, alter these variables as necessary:
startTimeCol = 1,
enteredExitedColumn = 0,
hoursDurationColumn = 3,
letterForHoursDurationColumn = "C",
@courtneyphillips
courtneyphillips / somefile.js
Created March 15, 2016 17:15
Async API Calls in Node Modules
// Because the ajax request is asynchronous, cannot assign data from api response to a variable in the success
// callback and return it, because the return statement will execute before the success function is completed.
// Instead, logic must happen inside of the success callback function.
// This can either mean using jQuery to directly display the response:
exports.getHumidity = function(city) {
$.get(url).then(function(response) {
$('.showWeather').text("The humidity in " + city + " is " + response.main.humidity + "%");
}).fail(function(error) {
@courtneyphillips
courtneyphillips / sample-component.js
Last active March 11, 2016 17:59
Using .intersect functionality of Ember Computed Properties in component
import Ember from 'ember';
export default Ember.Component.extend({
selectedSkills: Ember.inject.service(), // <-- service containing an array of objects.
selected: Ember.computed.alias('selectedSkills.skills'), // <-- giving 'selected' nickname to this array of objects within service.
skillsInCommon: Ember.computed.intersect('selected', 'project.skills'), // <-- returning only the objects present in both the service's array and in 'project.skills' (current model where this component is being called?)
});
@courtneyphillips
courtneyphillips / model.js
Created March 11, 2016 17:55
Ember.js computed property averaging value on `hasMany` Firebase relationship in model.
//this is the model for an object that has many reviews. reviews each contain a score. the averageScore property below gathers
// all reviews, sums all scores from all reviews, and divides by the number of reviews to calculate an average score.
import Ember from 'ember';
import DS from 'ember-data';
export default DS.Model.extend({
reviews: DS.hasMany('review', {async: true}),
...
@courtneyphillips
courtneyphillips / some-component.js
Last active February 25, 2016 22:44
Ember computed properties in components
//in component
import Ember from 'ember';
export default Ember.Component.extend({
sortProperties: ['date:desc'],
sortedAnswers: Ember.computed.sort('comments', 'sortProperties'),
actions: {
...
}
@courtneyphillips
courtneyphillips / Terminal
Last active March 15, 2016 17:18
Installing Ember on Epicodus Machines
From Home Directory, in the following order:
$ brew update
$ brew upgrade node
$ npm uninstall -g ember-cli
$ npm cache clean
$ bower cache clean
$ npm install -g [email protected]
@courtneyphillips
courtneyphillips / component.js
Last active March 15, 2016 17:20
Example Google Maps component in Ember.js with multiple markers with corresponding unique info windows.
showMap(foodcarts) {
this.set('mapShowing', true)
var coordArray = [];
var contentArray = [];
var markerarray = [];
foodcarts.forEach(function(foodcart) {
coordArray.push([foodcart.get('latitude'), foodcart.get('longitude')]),
contentArray.push([foodcart.get('name'), foodcart.get('website')])
});