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
{
"id": 1,
"extId": null,
"institutionId": 9,
"activityClubId": 1,
"repeatId": 636,
"coverImage": 2,
"title": "Superman i bio.",
"description": "t2",
"vacation": 0,
@null4bl3
null4bl3 / autoupdate.js
Created September 24, 2017 20:47
Loopback autoUpdate / autoMigrate server/boot script.
module.exports = function(app) {
var path = require('path');
var models = require(path.resolve(__dirname, '../model-config.json'));
var datasources = require(path.resolve(__dirname, '../datasources.json'));
function autoUpdateAll(){
Object.keys(models).forEach(function(key) {
if (typeof models[key].dataSource != 'undefined') {
if (typeof datasources[models[key].dataSource] != 'undefined') {
app.dataSources[models[key].dataSource].autoupdate(key, function (err) {

Keybase proof

I hereby claim:

  • I am null4bl3 on github.
  • I am w0rld3nd3r (https://keybase.io/w0rld3nd3r) on keybase.
  • I have a public key ASC8HfEXIRH9xFN_HxIMbmUVPPdxE9gp3BBF3x7VhrzrfQo

To claim this, I am signing this object:

@null4bl3
null4bl3 / nginx.nobots
Created October 19, 2017 08:28
Throws a 444 back at somewhat bad bots.
if ($http_user_agent ~* (360Spider|80legs.com|Abonti|AcoonBot|Acunetix|adbeat_bot|AddThis.com|adidxbot|ADmantX|AhrefsBot|AngloINFO|Antelope|Applebot|BaiduSpider|BeetleBot|billigerbot|binlar|bitlybot|BlackWidow|BLP_bbot|BoardReader|Bolt\ 0|BOT\ for\ JCE|Bot\ mailto\:craftbot@yahoo\.com|casper|CazoodleBot|CCBot|checkprivacy|ChinaClaw|chromeframe|Clerkbot|Cliqzbot|clshttp|CommonCrawler|comodo|CPython|crawler4j|Crawlera|CRAZYWEBCRAWLER|Curious|Curl|Custo|CWS_proxy|Default\ Browser\ 0|diavol|DigExt|Digincore|DIIbot|discobot|DISCo|DoCoMo|DotBot|Download\ Demon|DTS.Agent|EasouSpider|eCatch|ecxi|EirGrabber|Elmer|EmailCollector|EmailSiphon|EmailWolf|Exabot|ExaleadCloudView|ExpertSearchSpider|ExpertSearch|Express\ WebPictures|ExtractorPro|extract|EyeNetIE|Ezooms|F2S|FastSeek|feedfinder|FeedlyBot|FHscan|finbot|Flamingo_SearchEngine|FlappyBot|FlashGet|flicky|Flipboard|g00g1e|Genieo|genieo|GetRight|GetWeb\!|GigablastOpenSource|GozaikBot|Go\!Zilla|Go\-Ahead\-Got\-It|GrabNet|grab|Grafula|GrapeshotCrawler|GTB5|GT\:\:WWW|Guzz
@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
// 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 / node.js clear console
Created January 3, 2018 12:40
node.js clear console
process.stdout.write('\033c');
@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": [
{
"env": {
"node": true,
"es6": true
},
"rules": {
"semi": 2,
"indent": ["error", 2],
"arrow-body-style": [ ERROR, "always" ],
"arrow-parens": [ ERROR, "always" ],
@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";
}