Skip to content

Instantly share code, notes, and snippets.

@snowshoes
snowshoes / output
Created January 21, 2020 10:12 — forked from aheckmann/output
Mongoose 3.6 population example
===========
mongoose version: 3.6.0rc0
========
dbname: testing_populateAdInfinitum
[ { title: 'blog 1',
author:
{ _id: 511bde3e3985283f25000004,
===========
mongoose version: 3.6.0rc0
========
dbname: testing_populateAdInfinitum
[ { title: 'blog 1',
author:
{ _id: 511bde3e3985283f25000004,
@snowshoes
snowshoes / nginx1subapp.md
Created December 31, 2019 19:59 — forked from esfand/nginx1subapp.md
Nginx Location Ruels

Serving multiple webapps from different folders

November 29, 2011 developmentNginx

Few days ago I had to add a wordpress installation within the same environment where a Codeigniter app was already running happily and undisturbed.

It took me a while to figure out how to keep separate folders on the filesystem, and serve the blog from a subfolder of the main domain:

@snowshoes
snowshoes / secure-websockets
Created December 28, 2019 15:25 — forked from casecode/secure-websockets
Basic Config for SSL with Secure Websockets using Nginx 1.6.0 + Puma + Thin
=========================
# /etc/nginx/nginx.conf
=========================
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;

NodeJS debugging in VS Code with Nodemon

A simple NodeJS App debugging example in VS Code using Nodemon.

Note: Feel free to customize .vscode/launch.json and ./nodemon.json files.

Install

yarn add nodemon --dev

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
@snowshoes
snowshoes / iterm-fish-fisherman-meslo-osx.md
Last active June 21, 2019 22:48 — forked from ghaiklor/iterm-fish-fisherman-meslo-osx.md
iTerm 2 + fish + fisherman + Material Design + Meslo
@snowshoes
snowshoes / bcrypt-promise.js
Created June 20, 2019 12:45 — forked from dmh2000/bcrypt-promise.js
Using bcrypt with promises to hash a password and then verify it
let bcrypt = require('bcrypt-nodejs');
let password = "hello";
let stored_hash = "";
// first generate a random salt
function genSalt(password) {
return new Promise((resolve,reject) => {
bcrypt.genSalt(10,function(err,salt) {
if (err) {
@snowshoes
snowshoes / axios-catch-error.js
Created June 20, 2019 11:19 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨