- 🎨 when improving the format/structure of the code
- 🚀 when improving performance
- ✏️ when writing docs
- 💡 new idea
- 🚧 work in progress
- ➕ when adding feature
- ➖ when removing feature
- 🔈 when adding logging
- 🔇 when reducing logging
- 🐛 when fixing a bug
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 Promise = require('bluebird'); | |
| var sinon = require('sinon'); | |
| var User = require('./db/models').User; | |
| describe('User model', function(){ | |
| var userFindStub; | |
| var sandbox; | |
| before(function(){ | |
| sandbox = sinon.sandbox.create(); |
If you add emoji to your commit messages for a GitHub repo, they become less boring, and you can convey the kind of change you're adding. See the full set of GitHub supported emoji here (also useful for easy copy&paste via a simple click).
The following is a possible scheme to use:
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
| // takes a {} object and returns a FormData object | |
| var objectToFormData = function(obj, form, namespace) { | |
| var fd = form || new FormData(); | |
| var formKey; | |
| for(var property in obj) { | |
| if(obj.hasOwnProperty(property)) { | |
| if(namespace) { |
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 Sequelize = require('sequelize'); | |
| var DataTypes = Sequelize; | |
| sequelize = new Sequelize('mysql://root@localhost/29165644', {}); | |
| var Module = sequelize.define('module', { | |
| id: DataTypes.INTEGER, | |
| name: DataTypes.STRING, | |
| description: DataTypes.STRING, | |
| category_id: DataTypes.STRING, |
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
| // the main app file | |
| import express from "express"; | |
| import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db) | |
| import authenticate from "./authentication"; // middleware for doing authentication | |
| import permit from "./authorization"; // middleware for checking if user's role is permitted to make request | |
| const app = express(), | |
| api = express.Router(); | |
| // first middleware will setup db connection |
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
| combinations = [] | |
| amount = 12 | |
| def count_denoms(denoms, comb): | |
| global combinations | |
| for i in range(len(denoms)): | |
| comb_new = comb + [denoms[i]] | |
| if sum(comb_new) < amount: | |
| count_denoms(denoms[i:], comb_new) | |
| elif sum(comb_new) == amount: |
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
| # Heroku Django Commands # | |
| # ---------------------- # | |
| # Push local git changes to heroku | |
| git push heroku master | |
| # Login to heroku via toolbelt | |
| heroku login | |
| # View heroku processes |
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
| module.exports = { | |
| up: function (queryInterface, Sequelize) { | |
| return [ | |
| queryInterface.addColumn('User', 'name', { | |
| type: Sequelize.STRING | |
| }), | |
| queryInterface.addColumn('User', 'nickname', { | |
| type: Sequelize.STRING, | |
| }) | |
| ]; |
I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).
Use ssh keys and define host aliases in ssh config file (each alias for an account).
