-
Open Terminal move to your home folder:
cd ~ -
Enable git colors:
git config --global color.ui true -
Make a file called ".colors":
touch .colors -
Open .colors and paste the following:
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
| # ~/.gitconfig | |
| # Add this to your global git configuration file | |
| # Change phpstorm to webstorm, if you use that. | |
| # Diff and merge tool changes | |
| # Run `git difftool <directory/file>...` or `git mergetool <directory/file>...` | |
| [merge] | |
| tool = phpstorm | |
| [diff] | |
| tool = phpstorm |
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
| // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
| // Hooking up the middleware with the express app | |
| // In app.js | |
| // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
| var forceSSL = require('../middleware/ssl').force(config.hostname); | |
| if ('production' == app.get('env')) { | |
| app.use(forceSSL); | |
| } |
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
| function requireHTTPS(req, res, next) { | |
| if (!req.secure) { | |
| //FYI this should work for local development as well | |
| var domain = "https://" + req.get("host"); | |
| if (process.env["SSL_PORT"]) { | |
| domain = domain.replace(/:\d+$/, ""); | |
| domain += ":" + process.env["SSL_PORT"]; | |
| } | |
| return res.redirect(domain + req.url); | |
| } |
Summary: use good/established messaging patterns like Enterprise Integration Patterns. Don't make up your own. Don't expose transport implementation details to your application.
As much as possible, I prefer to hide Rabbit's implementation details from my application. In .Net we have a Broker abstraction that can communicate through a lot of different transports (rabbit just happens to be our preferred one). The broker allows us to expose a very simple API which is basically:
- publish
- request
- start/stop subscription
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
| public static string Base62Random() | |
| { | |
| int random = _random.Next(); | |
| return Base62ToString(random); | |
| } | |
| private static string Base62ToString(long value) | |
| { | |
| // Divides the number by 64, so how many 64s are in | |
| // 'value'. This number is stored in Y. |