Skip to content

Instantly share code, notes, and snippets.

@dam1r89
dam1r89 / stack.js
Created July 30, 2019 09:49
When manually trying find application bottleneck this snippet will pull stack trace ignoring node_modules and filtering only my application code.
try { throw Error() } catch (e) {
var stack = e.stack.split('\n').map(l => l.match(/\((.*).+\)/)).filter(Boolean)
.map(l => l[1])
.filter(l => !l.includes('node_modules') && l.includes('/app/'))
.slice(1, 4)
console.count('findByUserAndNetworkId: ' + stack.join(' -> '))
};
@dam1r89
dam1r89 / inith.sh
Created April 20, 2020 09:52
Run Laravel scheduler in docker container every minute
#!/bin/bash
# Start at :30 seconds
WAIT_FOR_MIDDLE_OF_MINUTE=$(( ( 90 - $(date +%S) ) % 60 ))
sleep $WAIT_FOR_MIDDLE_OF_MINUTE
START=$(date +%s%N)
INTERVAL_SECONDS=60
INTERVAL_NANOSECONDS=$(( $INTERVAL_SECONDS * 1000000000 ))
i=1
const express = require("express");
const querystring = require("querystring");
const session = require("express-session");
const app = express();
const port = 8080;
const url = `http://localhost:${port}`;
const oauthServer = "https://app.startinfinity.com";
const appId = "<paste-app-id>";