Skip to content

Instantly share code, notes, and snippets.

View daliborgogic's full-sized avatar
:octocat:
In Git we trust!

Dalibor Gogic daliborgogic

:octocat:
In Git we trust!
View GitHub Profile
module.exports = {
apps : [{
name: 'API',
script: 'app.js',
// Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
args: 'one two',
instances: 1,
autorestart: true,
watch: false,

Keybase proof

I hereby claim:

  • I am daliborgogic on github.
  • I am dlbr (https://keybase.io/dlbr) on keybase.
  • I have a public key ASBRbZLsoxpOQgpE9-Slx-iBxx2x4vVxXNUWq8ie_F2iUAo

To claim this, I am signing this object:

@daliborgogic
daliborgogic / awss3deleteolderthan.sh
Last active September 1, 2020 04:31
Delete files older than n in S3
#!/bin/bash
# Usage: . ./awss3deleteolderthan.sh [bucket] [path] "20 minutes ago"
endpoint="https://ams3.digitaloceanspaces.com"
aws s3 ls s3://$1/$2 --endpoint $endpoint --recursive | while read -r line;
do
createDate=`echo $line|awk {'print $1" "$2'}`
createDate=`date -d"$createDate" +%s`
@daliborgogic
daliborgogic / crontab
Last active July 18, 2019 22:43
Syncs directories and S3 prefixes. Recursively copies new and updated files from the source directory to the destination.
*/10 * * * * /home/dlbr/documents/scripts/s3sync.sh >> /home/dlbr/documents/logs/s3sync.log 2>&1
@daliborgogic
daliborgogic / project.sh
Last active July 16, 2019 21:54
Project Folder Structure
#!/bin/bash
# Project Folder Structure
# /project_name
# /assets
# /fonts
# /img
# /source
# /.git
# index.js
# package.json
export default [
['Region Hovedstaden', [10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]],
['Region Sjælland', [40,41,42,43,44,45,46,47,48,49]],
['Region Syddanmark', [50,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,70,71,72,73]],
['Region Midtjylland', [74,75,76,78,80,82,,83,84,85,86,88,89]],
['Region Nordjylland', [77,79,90,92,93,94,95,96,97,98,99]],
['Grønland', [39]]
]
@daliborgogic
daliborgogic / index.js
Last active June 14, 2019 19:42
[devicemoution] Listen to motion events and update the position
export default {
mounted () {
if (window.DeviceMotionEvent) {
// Listen to motion events and update the position
window.addEventListener('devicemotion', this.devicemotion, false)
}
},
destroyed () {
window.removeEventListener('devicemotion', this.devicemotion)
const query = {
bool: {
should: [
{
query_string: {
query: value,
type: 'cross_fields',
minimum_should_match: '100%',
analyze_wildcard: true,
fields: [
@daliborgogic
daliborgogic / index.js
Created May 20, 2019 15:18
Abortable Fetch
// This will allow us to abort the fetch
let controller
// Abort if the user clicks
abortBtn.addEventListener('click', () =>
if (controller) controller.abort()
)
// Load the content
loadBtn.addEventListener('click', async () => {
@daliborgogic
daliborgogic / index.js
Last active August 28, 2019 16:02
Split Business and Native errors Async/Await Node.js
const { parse } = require('url')
const fetch = require('node-fetch')
/*
Native Error types
@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types
*/
const nativeExceptions = [
EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError
].filter(except => typeof except === 'function')