This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Question 2.1 | |
1. In the show action of PostsController we create a new instance variable called "@post" and use the ActiveRecord ORM to generate a SQL query for our database that returns a collection of all entries in the "posts" table that have attribute "published = true" and where the "id" attribute from the "params" hash matches the "id" of the "post" entry. | |
We then use the ORMs "first" method to select the first object from the collection. | |
In the next line we check if "@post" is undefined or nil. If it is we set "@post" to the newest / latest entry in the database. | |
In the "posts/show" view we iterate over the "comments" for a "post" (usually identified by "post_id" attribute on "comment"), insert a paragraph for each comment and fetch and display the "user.name" and the "text" of the "comment". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
# require and extend MiniTest for test_custom_flatten method | |
require 'test/unit/assertions' | |
extend Test::Unit::Assertions | |
# custom_flatten flattens an n-dimensional array and | |
# returns a single dimensional array. | |
# | |
# custom_flatten only works with arrays | |
# where each element is either an Integer or a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0x222c914EEaA8e6010A74411C36Ac7b2c0a59CB01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var args = require('minimist')(process.argv.slice(2)); | |
var username = args.username; | |
var timeframe = args.timeframe; | |
var moment = require('moment'); | |
var InstagramPosts, streamOfPosts; | |
InstagramPosts = require('instagram-screen-scrape').InstagramPosts; | |
streamOfPosts = new InstagramPosts({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ember-cli-sentry will not be loaded from bower installation | |
Livereload server on http://0.0.0.0:5000 | |
Serving on http://0.0.0.0:4000/ | |
broccoli-babel-transpiler is opting out of caching due to a plugin that does not provide a caching strategy: `function (babel) { | |
var t = babel.types; | |
var replaceNodeWithPrecompiledTemplate = function(node, template) { | |
var compiledTemplateString = "Ember.HTMLBars.template(" + precompile(template) + ")"; | |
// Prefer calling replaceWithSourceString if it is present. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/services/pusher.js | |
channel.bind('executionStatus', (payload) => { | |
// find report with this executionId | |
const reports = this.get('store').peekAll('report'); | |
reports.forEach((report) => { | |
if (report.get('executionId') === payload.execution_id) { | |
if (payload.event === 'success') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"attribution":"<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">© Mapbox</a> <a href=\"https://openstreetmap.org/about/\" target=\"_blank\">© OpenStreetMap</a> <a class=\"mapbox-improve-map\" href=\"https://www.mapbox.com/map-feedback/\" target=\"_blank\">Improve this map</a>", | |
"bounds":[ | |
-180, | |
-85, | |
180, | |
85 | |
], | |
"created":1415246400000, | |
"description":"", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var printer = require('.'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var mapnik = require('mapnik'); | |
var url = require('url'); | |
var tilelive = require('tilelive'); | |
var tileliveVector = require('tilelive-vector'); | |
var tileliveTmstyle = require('tilelive-tmstyle'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{#power-select | |
selected=report.dashboardId | |
options=myDashboards | |
placeholder="Select a dashboard" | |
onchange=(action (mut report.dashboardId) value=dashboard.id) | |
as |dashboard| | |
}} | |
{{dashboard.name}} | |
{{/power-select}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/controllers/datasources/index.js | |
// 1 | |
datasources: Ember.computed.sort('model', 'name') | |
=> Uncaught Error: Assertion Failed: The sort definition for 'datasources' must be a function or an array of strings | |
// 2 | |
datasources: Ember.computed.sort('model', ['name']) | |
=> Uncaught Error: Assertion Failed: The key provided to get must be a string, you passed name |
NewerOlder