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

function check (string) {
var brackets = [], char = '', onStock = '';
for (var i = 0; i < string.length; i++) {
char = string[i];
if (char === "[" || char === "{" || char === "(") {
brackets.unshift(char);
}
if (char === "]" || char === "}" || char === ")") {
@lukaszewczak
lukaszewczak / getter
Created April 7, 2015 20:34
JS getter method
var box = {
locked: true,
unlock: function(){this.locked = false;},
lock: function(){this.locked = true;},
_content:[],
get content(){
if (this.locked) throw new Error("Locked");
return this._content;
}
};
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb
(function () {
'use strict';
var tpl =
['<html>\n<head></head>\n<body>',
'<div class="bs-docs-section">\n',
'<h1 id="code" class="page-header">Code</h1>\n<h2 id="code-inline">Inline</h2>\n',
'<p>Wrap inline snippets of code with <code>&lt;code&gt;</code>.</p>\n',
'<div class="bs-example" data-example-id="inline-code">\n',
'For example, <code>&lt;section&gt;</code> should be wrapped as inline.\n</div>\n',
@lukaszewczak
lukaszewczak / webstorm64.exe.vmoptions
Created October 6, 2014 21:13
webstorm64.exe.vmoptions
-ea
-server
-Xms1g
-Xmx1g
-Xss16m
-XX:ReservedCodeCacheSize=96m
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false
-XX:+UseCodeCacheFlushing
@lukaszewczak
lukaszewczak / status.bash
Created September 19, 2014 21:26
Repo status
git status
@lukaszewczak
lukaszewczak / clone.bash
Created September 19, 2014 21:25
Clone project
git clone [email protected]:nazwa-projektu.git
@lukaszewczak
lukaszewczak / existing_git_repo.bash
Created September 19, 2014 21:24
existing_git_repo
cd existing_git_repo
git remote add origin [email protected]:nazwa-projektu.git
git push -u origin master
@lukaszewczak
lukaszewczak / ssh_keygen.shell
Created September 19, 2014 21:15
Genarate ssh keygen
ssh-keygen -t rsa -C "[email protected]"