Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
@lukaszewczak
lukaszewczak / Docker
Created December 4, 2017 10:04 — forked from mitchwongho/Docker
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
@lukaszewczak
lukaszewczak / portable-node.md
Created November 23, 2017 11:52 — forked from domenic/portable-node.md
Tips for Writing Portable Node.js Code

Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.

Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.

Paths and URLs

On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation