Skip to content

Instantly share code, notes, and snippets.

* 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.
@tahoeRobbo
tahoeRobbo / mongoose-cheatsheet.md
Created January 6, 2020 20:49 — forked from subfuzion/mongoose-cheatsheet.md
mongoose cheatsheet

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.

Install

$ npm install mongoose --save

Connect

const mongoose = require('mongoose');
@tahoeRobbo
tahoeRobbo / frontendDevlopmentBookmarks.md
Created February 2, 2018 22:56 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
@tahoeRobbo
tahoeRobbo / hackerRankExample.js
Last active September 25, 2015 17:59 — forked from mhart/test1.js
stdin/stdout pipe in node.js
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;
});
@tahoeRobbo
tahoeRobbo / angularjs_directive_attribute_explanation.md
Last active August 29, 2015 14:26 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

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.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@tahoeRobbo
tahoeRobbo / app.js
Last active August 29, 2015 14:24 — forked from katowulf/app.js
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
@tahoeRobbo
tahoeRobbo / stringifiedNumBackToNum
Last active August 29, 2015 14:24
Ways of converting a stringified number back to a good ole number number
//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);
@tahoeRobbo
tahoeRobbo / uploadImageToFirebase
Last active February 2, 2016 02:27
Example Uploading an Local Image to Firebase using FileReader
/*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 = {
@tahoeRobbo
tahoeRobbo / onAuthRootScopeCurrentUserExmp
Last active August 29, 2015 14:23
passing full user info to $rootScope.currentUser and making it available throughout the application
// 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