Skip to content

Instantly share code, notes, and snippets.

View aitchkhan's full-sized avatar
💭
Ehsaan

Haroon Khan aitchkhan

💭
Ehsaan
View GitHub Profile
{
"data": {
"message": "User unauthorized",
"type": "Unauthorized error",
"code": 401
},
"success": true
}
@aitchkhan
aitchkhan / gist:757ac1ddcd8f50bf593c2a0384abf019
Created December 20, 2016 01:00
Error while runnung command $npm start
[05:57:49] Finished 'clean.once' after 742 ms
[05:57:49] Starting 'build.assets.dev'...
[05:57:50] Finished 'build.assets.dev' after 346 ms
[05:57:50] Starting 'build.fonts'...
[05:57:50] Finished 'build.fonts' after 147 ms
[05:57:50] Starting 'build.html_css'...
[05:57:52] Finished 'build.html_css' after 2.26 s
[05:57:52] Starting 'build.js.dev'...
src/client/app/frameworks/teamwork/services/teamwork.service.ts(5,25): error TS2307: Cannot find module 'base-64'.
[05:57:59] TypeScript: 1 semantic error
const multer = require('multer');
const path = require('path');
const config = require('../config/index');
const pathToUploads = config.uploadDestination;
const limits = {
fileSize: 5242880
}
@aitchkhan
aitchkhan / api.js
Last active January 11, 2017 12:10
'use strict';
var express = require('express');
var controller = require('./post.controller');
const fileUpload = require('../../lib/helpers/fileUpload');
var router = express.Router();
router.get('/', controller.index);
router.get('/:id', controller.getPostById);
router.post('/', fileUpload.single('image'), controller.createPost2); //this is how it is going to consume in an api or endpoint
@aitchkhan
aitchkhan / $push.js
Created February 2, 2017 12:26
pushes multiple embedded doc to an array
//pushes multiple embedded doc to array
db.latestItems.update({}, {
$push: {
items: {
$each: [ {item_name: 'third item', price: 20 }, {item_name: 'forth item', price: 50 }]
}
}
1. How callbacks work!!
2. Closure.
3. Prototypes.
ES6 Concepts
Let and const
classes and inheritance
teplate literals
string methods and number methods
default params and spread operator
set maps weakset weakmap
@aitchkhan
aitchkhan / launch.json
Created December 4, 2017 13:02
VS-Code configuration for debugging CINC server, scheduler, tests
// add this in configuration block
{
"type": "node",
"request": "launch",
"name": "Debug Server",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug"
@aitchkhan
aitchkhan / aggregates.js
Created December 8, 2017 03:38
Here is a sample test written with mocha + chai + sinon
describe('Error case(s)', () => {
it('should return type required error', (done) => {
repos.favorites.contentIdsCount.resolves(contentIdsCountResponse);
expect(services.aggregates.view({skip: 0, pageSize: 15, type: 'randomType'}))
.to.eventually.be.rejected.and.be.an.instanceOf(errorHelper.BadRequestError)
.and.eventually.deep.equal(new errorHelper.BadRequestError([messages.validation.aggregateType.enum]))
.notify(done);
});
});
@aitchkhan
aitchkhan / git.txt
Last active March 7, 2018 09:58
git
delete branches that are merged in master develop
git branch --merged | egrep -v "(^\*|master|develop)" | xargs git branch -d
@aitchkhan
aitchkhan / pizzas.sql
Created January 9, 2019 15:31
Pizzas for winter school
//create database:
create database pizzaApi;
// create ingredients table:
CREATE TABLE `ingredients` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`key` VARCHAR(45) NOT NULL,