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
@daliborgogic
daliborgogic / instagram.js
Last active October 4, 2019 10:27
Instagram Graph API Media
const fetch = require('node-fetch')
const { FB_PAGE_ID, FB_ACCESS_TOKEN } = process.env
const { getParams } = require('./helpers')
const GRAPH_URL = 'https://graph.facebook.com/v4.0'
const headers = { 'content-type': 'application/json' }
const options = { headers }
let params = { access_token: FB_ACCESS_TOKEN }
@daliborgogic
daliborgogic / localhost.sh
Created September 9, 2019 18:14
The simplest way to generate a private key and self-signed certificate for localhost.
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
@daliborgogic
daliborgogic / .aliases
Last active September 10, 2019 10:15
DNS over HTTPS (DoH) in Google Chrome
# Google Chrome
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
alias chromedoh='chrome --enable-features="dns-over-https<DoHTrial" --force-fieldtrials="DoHTrial/Group1" --force-fieldtrial-params="DoHTrial.Group1:server/https%3A%2F%2F1.1.1.1%2Fdns-query/method/POST"'
@daliborgogic
daliborgogic / Dockerfile
Last active August 18, 2023 06:47
Best-Practice Docker Image and GitHub Workflow for Node.js app. [Continuous Integration/Delivery/Deployment]
ARG VERSION=12.10.0
# Development ##################################################################
FROM mhart/alpine-node:${VERSION} AS dev
WORKDIR /app
COPY package*.json .gitignore ./
ENV HOST=0.0.0.0
ENV PORT=${PORT}
RUN npm ci --prefer-offline
COPY . .
FROM mhart/alpine-node:12.9.1
RUN npm i -g pkg
RUN which pkg
COPY package*.json /app/
RUN cd /app; npm ci \
&& npm run build \
&& /usr/bin/pkg -t node12-linux --output .dist .
COPY . /app
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