This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Make sure you added pm2 as a dependency in your package.json | |
| // Then in your Procfile, do a simple `node bootstrap.js` | |
| var pm2 = require('pm2'); | |
| var MACHINE_NAME = 'hk1'; | |
| var PRIVATE_KEY = 'z1ormi9vomgq66'; | |
| var PUBLIC_KEY = 'oa0m7nuhdfibi16'; | |
| var instances = process.env.WEB_CONCURRENCY || -1; // Set by Heroku or -1 to scale to max cpu core -1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var db = mongoose.connect('mongodb://localhost:27017/DB'); | |
| // In middleware | |
| app.use(function (req, res, next) { | |
| // action after response | |
| var afterResponse = function() { | |
| logger.info({req: req}, "End request"); | |
| // any other clean ups |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env xcrun swift | |
| import Foundation | |
| public typealias CharactersArray = [Character] | |
| public typealias CharactersHash = [CharactersGroup : CharactersArray] | |
| public enum CharactersGroup { | |
| case Letters | |
| case Numbers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| My thoughts on writing tiny reusable modules that each do just one | |
| thing. These notes were adapted from an email I recently sent. | |
| *** | |
| If some component is reusable enough to be a module then the | |
| maintenance gains are really worth the overhead of making a new | |
| project with separate tests and docs. Splitting out a reusable | |
| component might take 5 or 10 minutes to set up all the package | |
| overhead but it's much easier to test and document a piece that is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var contacts = | |
| [ | |
| { | |
| "notes": [ | |
| { | |
| "description": "Fugiat aute pariatur excepteur elit." | |
| } | |
| ], | |
| "tels": [ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <UIKit/UIKit.h> | |
| #import <ImageIO/ImageIO.h> | |
| #import <MobileCoreServices/MobileCoreServices.h> | |
| static UIImage *frameImage(CGSize size, CGFloat radians) { | |
| UIGraphicsBeginImageContextWithOptions(size, YES, 1); { | |
| [[UIColor whiteColor] setFill]; | |
| UIRectFill(CGRectInfinite); | |
| CGContextRef gc = UIGraphicsGetCurrentContext(); | |
| CGContextTranslateCTM(gc, size.width / 2, size.height / 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // CollectionViewDataSource.swift | |
| // Khan Academy | |
| // | |
| // Created by Andy Matuschak on 10/14/14. | |
| // Copyright (c) 2014 Khan Academy. All rights reserved. | |
| // | |
| import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Books: | |
| ** Disclaimer: I've only read the first two. The second one is a little dry and I feel like most people might not like it, | |
| but I enjoyed it ** | |
| ** Was told by someone I respect that if he only had to choose one book it would be book #1 ** | |
| 1. Design Patterns: Elements of Reusable Object-Oriented Software | |
| https://www.amazon.com/dp/0201633612/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This function implements anonymous creation logic. | |
| function loadOrCreateAnonymousProfile(req, res, next) { | |
| var sess = req.session, | |
| auth = sess && sess.auth; | |
| if (!auth || !auth.userId) { | |
| dbCounter('anonymousUsers', function(err, counter) { | |
| if (err) { | |
| console.log('Error getting anonymous users counter', err); | |
| next(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tweetstream: node twitter-pubnub-stream.js |