Skip to content

Instantly share code, notes, and snippets.

@cahlan
cahlan / walkthrough.md
Last active October 11, 2018 23:16
Sarah Wiley's walkthrough of Erebos, Morpheus-UI, and Bluzelle POC

Setup

  • Install/run local swarm node (referenced at localhost:8500)

  • Install/run local Bluzelle swarm (referenced at my IP address on port 51010)

  • Install/run Bluzelle CRUD visualizer tool

Running the App:

@cahlan
cahlan / queries.js
Last active December 2, 2015 17:45
some sample mongodb/mongoose queries
//given this schema ...
// {
// [id]
// name: String,
// email: String,
// bio: String,
// createdAt: Date,
// age: 11
// }

What if we were trying to access data from a domain we weren't hosting on? In other words, what if we had a site on http://example.com but we needed to get data from another domain of ours, http://awesome.com? Because of Same-origin policy implemented by browsers, we can't do this. By default, browsers will only allow Javascript to manipulate or access API resources that originate from the same domain. There are times where we do want communication to happen across domains, which is why we can implement special HTTP headers that define a cross-origin policy and thus allow us to access data across separate domains.

In Node, use this header for simple cross site request blocking:

res.setHeader('X-XSS-Protection', '1; mode=block');

If we want to have data accessible from other domains, we'd need to add the appropriate ‘Access-Control-Allow-Origin’ headers to make this possible:

Firebase: Flipped

Description

For the next two days, we're "flipping" the classroom. Flipped classrooms are a very recent technique used by educators to maximize the effectiveness of an in-person class experience. If you use the time effectively, you'll get farther in the next two days during the flipped portion than you would have in a normal setting.

The basic philosophy behind the flipped classroom is that you'll take time on your own to review the lecture before class. This will allow us to spend classtime answering questions, resolving confusion, and expanding what was learned during the lecture. Ultimately, you'll be better prepared for your day's projects and further along as a developer.

For the next two days, you'll be watching two lectures by Chris Esplin, a Firebase expert. He's a part of the Google Developer Experts program and a guest instructor at DevMountain.

@cahlan
cahlan / example-service-sequential.js
Created November 6, 2015 14:32
example of using a parallelized promise to grab a collection of network data
this.getFilms = function(char) {
var deferred = $q.defer();
//this array will hold references to all of the $http calls that need to be made
var film_requests = [];
for (var i = 0; i < char.films.length; i++) {
film_requests.push(
$http({
method: 'GET',
var mongojs = require('mongojs');
var db = mongojs('test');
var users = db.collection('users');
//find all
// users.find(function(err, users) {
// console.log(err, users);
// });
@cahlan
cahlan / gist:d9acb73e1ab56e980cc2
Created March 10, 2015 22:01
simple promise API for handing success/error/other in NG
//controller.js
myService.getStuff().then(function() {
//upon deferred.resolve
}).catch(function(err) {
//upon deferred.reject
}).finally(function() {
//no matter what
@cahlan
cahlan / gist:336007c62e6716b31a94
Created March 10, 2015 20:49
sample nginx for hosting multiple apps/domains on a single droplet
# install nginx
# sudo apt-get install nginx
# configure nginx
# /etc/nginx/sites-available/[myconfigfile]
# create symlink /\ \/
# /etc/nginx/sites-enabled/[myconfigfile]
@cahlan
cahlan / javasc
Created February 13, 2015 18:38
example of queries with a sample controller (node, express, mongoose)
module.exports = {
getCustomer: function(req, res) {
///api/customers/:id
Customer.findOne({_id: req.params.id}).exec().then(function(err, user) {
return res.json(user);
});
},
getCustomers: function(req, res) {
var sort = req.query.sort || '-createdAt';
var skip = req.query.skip || 0;
@cahlan
cahlan / gist:15a3b7c07c9dbbd01b92
Created February 13, 2015 18:21
demonstration of schema methods and bcrypt
//User, pseudo code!!!!!
var userSchema = {
name: String,
email: String,
password: String,
gender: String,
bio: String,
createdAt: Date,
age: {type: Number, min: 0, max: 99}
};