Skip to content

Instantly share code, notes, and snippets.

@delwar2016
delwar2016 / Using Sinon to stub Mongoose calls and return Promise
Last active May 23, 2023 08:25
Using Sinon to stub Mongoose calls and return Promise
Suppose we have a schema as follows
var User = require('./schemas/UserSchema').User;
and we want to write unit test for like bellow code:
var getUserById = function () {
return User.findOne({_id: '001'}).exec();
};
@delwar2016
delwar2016 / install SSL certificate
Last active October 9, 2017 10:55
install SSL certificate
https://certbot.eff.org/#ubuntutrusty-nginx
https://askubuntu.com/questions/363200/e-unable-to-correct-problems-you-have-held-broken-packages
Use aptitude instead of apt-get. It is more intelligent. It not only will handle downgrading conflicting packages for you, but will make a series of recommendations asking you which of many possible suggested working scenarios you would like.
sudo aptitude install myNewPackage
If you don't have aptitude on your machine yet, get it with
@delwar2016
delwar2016 / Google Extension
Created July 19, 2017 14:27
Google Extension
Need to create extension:
1. manifest.json
2. 19x19px PNG file
3. popup.html
4. popup.js
@delwar2016
delwar2016 / socket.id
Created July 14, 2017 13:51
socket.id
https://gist.github.com/crtr0/2896891
https://socket.io/docs/rooms-and-namespaces/
@delwar2016
delwar2016 / generator-backbone-fullstack
Last active July 13, 2017 16:01
generator-backbone-fullstack
npm -g install yo
npm -g install generator-backbone
https://books.google.com.bd/books?id=5NPGAwAAQBAJ&pg=PA143&lpg=PA143&dq=generator-backbone-fullstack&source=bl&ots=txake5LXcg&sig=S_2RU2sUcHy5ePYV7dG4BSS8u_Q&hl=en&sa=X&redir_esc=y#v=onepage&q&f=false
https://github.com/yeoman/generator-backbone#readme
https://github.com/pusongyang/generator-fullstack-backbone
@delwar2016
delwar2016 / Installation .Net Code onUbuntu 14.04
Last active June 21, 2017 19:58
Installation .Net Code onUbuntu 14.04
https://www.microsoft.com/net/core#linuxubuntu
https://stackoverflow.com/questions/37460631/asp-net-core-test-site-cant-be-reached
The Kestrel web server defaults to listening on localhost:5000, so if you haven't changed what host it listens on you won't be able to connect to it from a remote machine (or in your case, the host machine).
There are several ways that you can configure Kestrel to listen on a different host or port. The simplest implementation would be to add the line .UseUrls("http://0.0.0.0:5000") right after .UseKestrel() in your Main method. This would make the application listen on all available IP addresses using port 5000.
Update
@delwar2016
delwar2016 / Understanding NodeJs Express Middleware
Last active June 8, 2017 17:48
Understanding NodeJs Express Middleware
Middleware functions can perform the following tasks:
1. Execute any code.
2. Make changes to the request and the response objects.
3. End the request-response cycle.
4. Call the next middleware function in the stack.
@delwar2016
delwar2016 / git add new repo
Created April 28, 2017 06:41
git add new repo
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
@delwar2016
delwar2016 / Install RTMP
Last active April 20, 2017 01:33
Install RTMP
Link: https://obsproject.com/forum/resources/how-to-set-up-your-own-private-rtmp-server-using-nginx.50/
apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
wget http://nginx.org/download/nginx-1.9.15.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
@delwar2016
delwar2016 / FTP instalation
Last active April 6, 2017 11:38
FTP instalation
Source: https://www.liquidweb.com/kb/how-to-install-and-configure-vsftpd-on-ubuntu-14-04-lts/
https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-ubuntu-quickstart