Definitely not comprehensive. This is meant to be a basic memory aid with links to get more details. I'll add to it over time.
$ npm install mongoose --save
const mongoose = require('mongoose');
| * Promise vs Observable | |
| * Promise | |
| * Single async event that can either complete or fail once. | |
| * Can be used with async/await keywords. | |
| * Observable | |
| * Can emit multiple events async. | |
| * Offers a bit more control over the async task, for example cancelling. | |
| * Cannot be used with async/await keywords. | |
| * Think of Observables as a stream of data instead of an async task. | |
| * Observable is the default used in Angular, but promises are still fine to use. |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
| process.stdin.resume(); | |
| process.stdin.setEncoding('ascii'); | |
| var input_stdin = ""; | |
| var input_stdin_array = ""; | |
| var input_currentline = 0; | |
| process.stdin.on('data', function (data) { | |
| input_stdin += data; | |
| }); |
When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.
Raw Attribute Strings
<div my-directive="some string" another-param="another string"></div>| var app = angular.module('app', ['firebase']); | |
| app.controller('ctrl', function($scope) { | |
| var ref = new Firebase('https://fbutil.firebaseio.com/paginate'); | |
| $scope.scrollItems = $scrollArray(ref, 'number'); | |
| }); | |
| app.factory('$scrollArray', function($firebaseArray) { | |
| return function(ref, field) { | |
| // create a special scroll ref |
| //Quick gist to prove the three ways (that I know of) to turn stringified numbers back into numbers in JavaScript. | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| //This can be done using parseInt(stringifiedNum), Number(stringifiedNum), and +stringifiedNum. | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| //See lines 10, 18, and 26 for usage | |
| var add10 = function(numArray) { | |
| var added10 = []; | |
| for(var i = 0; i < numArray.length; i++) { | |
| added10.push(+numArray[i] + 10); |
| /*CORRECT WORKING FUNCTION TO CONVERT TO BASE 64 AND DISPLAY PREVIEW*/ | |
| //var readFile; | |
| var previewFile = function() { | |
| var preview = document.querySelector('#preview'); | |
| var file = document.querySelector('input[type=file]').files[0]; | |
| var reader = new FileReader(); | |
| reader.onloadend = function() { | |
| preview.src = reader.result | |
| } |
| angular.module('app') | |
| .controller('ImageUpload', ['$scope', '$log', | |
| function ImageUpload($scope, $log) { | |
| $scope.upload_image = function (image) { | |
| if (!image.valid) return; | |
| var imagesRef, safename, imageUpload; | |
| image.isUploading = true; | |
| imageUpload = { |
| // in the registration service... | |
| //Register the user, and once registered create the firebaseObj with the full user info (which was input via registrationTmpl.html) | |
| this.register = function(user) { | |
| return auth.$createUser({ | |
| email: user.email, | |
| password: user.password | |
| }).then(function(regUser) { | |
| console.log(regUser) | |
| //regUser.uid.replace('simplelogin', ''); //TRYING TO REMOVE SIMPLELOGIN NOT WORKING |