Skip to content

Instantly share code, notes, and snippets.

@lukaszewczak
lukaszewczak / better-nodejs-require-paths.md
Created February 8, 2016 20:43 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@lukaszewczak
lukaszewczak / gist:695cf5c84d960a452133
Created February 22, 2016 15:04 — forked from sl4m/gist:5091803
create self-signed certificate for localhost
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@lukaszewczak
lukaszewczak / make.sh
Created June 9, 2016 11:09 — forked from artzub/make.sh
Install JetBrains Hub + YouTrack + UpSource + Nginx
#!/bin/bash
apt-get install mc htop git unzip wget curl -y
echo
echo "====================================================="
echo " WELCOME"
echo "====================================================="
echo
echo "Hub"
@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

@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 / 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 / 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 / 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 / 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);
}