Skip to content

Instantly share code, notes, and snippets.

@jannunzi
jannunzi / m3.js
Created September 27, 2020 14:36
const m3 = {
projection: function(width, height) {
// Note: This matrix flips the Y axis so that 0 is at the top.
return [
2 / width, 0, 0,
0, -2 / height, 0,
-1, 1, 1
];
},
[
{
"id": "123",
"title": "Course 1",
"modules": [
{
"id": "123",
"title": "Module 1 1",
"lessons": [
{
@jannunzi
jannunzi / users.json
Last active September 21, 2018 17:16
[
{
"id": "123",
"username": "alice",
"password": "alice",
"email": "alice@wonderland.com",
"firstName": "Alice",
"lastName": "Wonderland",
"role": "FACULTY"
},
[
{
"id": "123",
"title": "CS5610",
"modules": [
{
"title": "Week 1",
"lessons": [
{
"title": "HTML",
[
{
"meta": {
"grade": {
"list": [
"9",
"10",
"11",
"12"
]
config.js
(function() {
angular
.module("EmployeeApp")
.config(Config);
function Config(<--1--> ) {
$routeProvider
.when("/user/:uid", {
template: "user.view.html",
controller: "UserController"
function login(req, res) {
var user = req.user;
res.json(user);
}
function logout(req, res) {
req.logOut();
res.send(200);
}
passport.serializeUser(serializeUser);
passport.deserializeUser(deserializeUser);
function serializeUser(user, done) {
done(null, user);
}
function deserializeUser(user, done) {
userModel
.findUserById(user._id)
var userModel = require("../../models/user/user.model.server.js")();
var LocalStrategy = require('passport-local').Strategy;
passport.use(new LocalStrategy(localStrategy));
function localStrategy(username, password, done) {
userModel
.findUserByCredentials({username: username, password: password})
.then(
function(user) {
if (!user) { return done(null, false); }
return done(null, user);
var passport = require('passport');
var auth = authorized;
app.post ('/api/login', passport.authenticate('local'), login);
app.post ('/api/logout', logout);
app.post ('/api/register', register);
app.post ('/api/user', auth, createUser);
app.get ('/api/loggedin', loggedin);
app.get ('/api/user', auth, findAllUsers);
app.put ('/api/user/:id', auth, updateUser);
app.delete('/api/user/:id', auth, deleteUser);