Skip to content

Instantly share code, notes, and snippets.

upstream api_node_js {
server 127.0.0.1:4000;
}
server {
listen 80;
listen [::]:80;
root /var/www/webapp/dist;
@lukaszewczak
lukaszewczak / ReadMe.md
Created May 20, 2019 04:22 — forked from edm00se/ReadMe.md
Sample nginx.conf settings to perform reverse proxy functionality to.

Read Me

In order to access a server hosted within a vm (guest), for development purposes from the host OS, which is restricted to same origin / localhost only requests, I set up a siple nginx reverse proxy to forward my requests.

Steps

  1. To install in a Windows VM, download and install nginx from the current, stable release; I installed to C:\nginx\
  2. Edit the <install path>/conf/nginx.conf file with the marked changes in the file of the same name in this gist.
  3. Start the nginx executable, located in your install path. There are service wrappers for Windows, or you can just kill the process to stop the nginx instance.

Commands for Windows

@lukaszewczak
lukaszewczak / update.md
Last active February 17, 2019 04:32
Update all package.json dependencies

Sometimes, when working with tutorials, I just want to update all of the project depedencies, so this how I do it.

node -p "const json=require('./package.json');const depedencies=Object.keys(json.dependencies).reduce((prev,item)=>`${prev} ${item}@latest`,''); require('child_process').exec(`npm install ${depedencies}`)
@lukaszewczak
lukaszewczak / docker.md
Created December 3, 2018 14:28 — forked from developerinlondon/docker.md
Docker saving and loading images

Here's how to save and load docker images:

Example scenario: To save a docker image from a docker repository and save it as a tar file locally.

  1. Save the image as a tarball

docker save repositoryname:tag > repotag.tar

  1. Zip the image
@lukaszewczak
lukaszewczak / Secure Sessions Howto
Created October 12, 2018 09:05 — forked from nikmartin/A: Secure Sessions Howto
Secure sessions with Node.js, Connect, and Nginx as an SSL Proxy
Secure sessions are easy, but it's not very well documented, so I'm changing that.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [CLIENT]
To do this, here's what you need to do:
@lukaszewczak
lukaszewczak / promise-test.js
Created August 9, 2018 09:31 — forked from haroldtreen/promise-test.js
Testing promise rejection with Mocha
const { assert } = require('chai');
function isError(e) {
if (typeof e === 'string') {
return Promise.reject(new Error(e));
}
return Promise.resolve(e);
}
@lukaszewczak
lukaszewczak / docker-cleanup-resources.md
Created August 3, 2018 10:58 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@lukaszewczak
lukaszewczak / keybase.md
Created April 19, 2018 09:26
Keybase proof

Keybase proof

I hereby claim:

  • I am lukaszewczak on github.
  • I am lukaszewczak (https://keybase.io/lukaszewczak) on keybase.
  • I have a public key ASAkuGZRO-mO_LuPODWZLBUZaaeW---1yL3FMK3rt4_0Jwo

To claim this, I am signing this object:

@lukaszewczak
lukaszewczak / gist:6a4b3c80864fe5dab7fc71a17eb5bc77
Created April 7, 2018 04:14 — forked from clintberry/gist:6420200
Websocket service with pending functions until websocket opened.
'use strict';
angular.module('guiApp')
.service('Websocket', function Websocket($q, $rootScope, PubSub) {
var Service = {}; // Object to return for the service
var callbacks = {}; // Keep all pending requests here until they get responses
var currentCallbackId = 0; // Create a unique callback ID to map requests to responses
var ws = null; // Initialize our websocket variable
var connectStatus = false; // Is the websocket connected?
@lukaszewczak
lukaszewczak / free-space-on-boot-disk.md
Created January 11, 2018 08:18 — forked from jbgo/free-space-on-boot-disk.md
Free up space on /boot disk (ubuntu)

Free disk space when /boot is full (Ubuntu)

TL;DR

dpkg -l linux-image*
uname -r
sudo apt-get remove linux-image-2.6.32-{21,37,38,39,40,41,42,43,44}-server
sudo apt-get autoremove