Skip to content

Instantly share code, notes, and snippets.

app.post('/api/posts', function(req, res) {
var post = new Post();
post.name = req.body.name;
post.desc = req.body.desc;
post.quantity = req.body.quantity;
post.time = new Date();
post.save(function(err) {
if (err) {
res.send(err);
app.get('/api/posts', function(req, res) {
Post.find(function(err, posts) {
// if there is an error retrieving, send the error
// nothing after res.send(err) will execute if there is one
if (err) {
res.send(err);
}
res.json(posts);
});
});
//
// CameraViewController.swift
// SpotWalk
//
// Created by Alex Persian on 10/25/15.
// Copyright © 2015 alexpersian. All rights reserved.
//
import UIKit
import AVFoundation
//TODO: Write a test for the hex string -> UIColor conversion
func checkHexStringForDateString(dateString: String) {
// given
let changes: [String: String] = [
"1" : "A",
"2" : "B",
"3" : "C",
"4" : "D",
"5" : "E",
"6" : "F"
@alexpersian
alexpersian / managerExample.swift
Created December 12, 2015 21:09
Example of a previous manager class I've made
//
// HandleUserDefaults.swift
// Student
//
// Created by Alex Persian on 6/9/15.
// Copyright (c) 2015 Geo-Comm Inc. All rights reserved.
//
import Foundation
struct Dispatch {
private func once(var predicate: Bool, block: () -> Void) {
if !predicate {
block()
predicate = true
}
}
}
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
func dispatchOnce(_ predicate: inout Bool, _ block: @noescape () throws -> Void) rethrows {
objc_sync_enter(predicate)
if !predicate {
do {
predicate = true
Process: SwiftyJSONAccelerator [3024]
Path: /Volumes/VOLUME/*/SwiftyJSONAccelerator.app/Contents/MacOS/SwiftyJSONAccelerator
Identifier: com.karthik.SwiftyJSONAccelerator
Version: 0.0.6 (6)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: SwiftyJSONAccelerator [3024]
User ID: 501
Date/Time: 2016-10-01 11:15:35.540 -0400