Skip to content

Instantly share code, notes, and snippets.

View null4bl3's full-sized avatar

Martin Nielsen null4bl3

  • DTU Wind Energy
  • Denmark
View GitHub Profile
@null4bl3
null4bl3 / VSCODIUM
Last active November 22, 2018 20:40
Vscodium Settings Sync Gist
{"lastUpload":"2018-11-22T13:37:58.709Z","extensionVersion":"v3.2.0"}
let chalk = require('chalk');
let moment = require("moment");
let winston = require('winston');
require('winston-mongodb');
const { format } = require('winston');
const { combine, timestamp, label, prettyPrint } = format;
const levels = {
error: 0,
warn: 1,
let chalk = require('chalk');
module.exports = function (app) {
/**
* CLIENT INTERACTION SYSTEM LOG
*
* @param {*} _message
* @param {*} _action
* @param {*} _type
@null4bl3
null4bl3 / .zshrc
Created May 17, 2018 11:48
Alias and functions from my .zshrc
# ALIAS
alias lll='ls -Alhtr' # sorts files in dir by date
alias cl='clear'
alias mi='micro '
alias nicer='python -m json.tool'
alias ccat='pygmentize -g -O style=colorful,linenos=1'
alias catline='pygmentize -g -O style=colorful,linenos=1'
alias xx='sudo systemctl start mariadb.service'
alias xxx='sudo systemctl stop mariadb.service'
alias zz='screen -dmS mongod mongod'
@null4bl3
null4bl3 / format_bytes.js
Created May 14, 2018 13:18
return a ceil + parseint value
formatBytes(bytes) {
if (bytes < 1024) {
return bytes + " Bytes";
} else if (bytes < 1048576) {
return parseInt(Math.ceil(bytes / 1024).toFixed(3), 10) + " KB";
} else if (bytes < 1073741824) {
return parseInt(Math.ceil(bytes / 1048576).toFixed(3), 10) + " MB";
} else {
return parseInt(Math.ceil(bytes / 1073741824).toFixed(3), 10) + " GB";
}
{
"env": {
"node": true,
"es6": true
},
"rules": {
"semi": 2,
"indent": ["error", 2],
"arrow-body-style": [ ERROR, "always" ],
"arrow-parens": [ ERROR, "always" ],
@null4bl3
null4bl3 / loopback_static_files.json
Last active January 31, 2018 12:18
Loopback lets you define middleware for serving static files. This is the examples with path i keep looking for
"files": {
"loopback#static": [
{
"paths": [
"/"
],
"params": "$!../client/dist"
},
{
"paths": [
@null4bl3
null4bl3 / node.js clear console
Created January 3, 2018 12:40
node.js clear console
process.stdout.write('\033c');
// THIS EXAMPLE IS BASED ON LOOPBACK, BUT ANY LOGIC CAN REPLACE THE isAuthenticated()
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { LoginApi } from './shared/sdk';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private _loginApi: LoginApi) { }
canActivate() {
@null4bl3
null4bl3 / multitail.use
Created October 23, 2017 14:20
A thousand lines of pretty colors with multitail
multitail -C -c -n 1000 /path/to/file