Skip to content

Instantly share code, notes, and snippets.

🔥
In case of fire: git commit, git push, leave the building!

Dalibor Gogic daliborgogic

🔥
In case of fire: git commit, git push, leave the building!
Block or report user

Report or block daliborgogic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@daliborgogic
daliborgogic / Img.vue
Last active Nov 12, 2019
Conditionaly load img based on current users download speed and users choice to save data.
View Img.vue
<template>
<img :src="srcImage" :loading="loading" :alt="alt">
</template>
<script>
export default {
props: {
src: {
type: Object,
default: () => ({
@daliborgogic
daliborgogic / backup-files.sh
Last active Nov 8, 2019
I like to move it move it Google Cloud Bucket
View backup-files.sh
#!/bin/bash
# . ./backup-files.sh from to
# Variables
WHAT=`date +%d%m%y%H%M%S`.tar.gz
WHERE=gs://$2/$WHAT
SMALLER_ARE_BETTER="tar -czvf $WHAT $1"
targz(){
View index.js
async function foo (method, url, body) {
if (!url) throw new Error()
let config = {
headers: { accept: 'application/json' }
}
if (method && body) {
config.body = JSON.stringify(body)
config.method = method
}
const res = await fetch(url, { config })
View debounce.js
export default function (func, wait, immediate) {
var timeout
return function() {
var context = this, args = arguments
var later = function() {
timeout = null
if (!immediate) func.apply(context, args)
}
var callNow = immediate && !timeout
clearTimeout(timeout)
@daliborgogic
daliborgogic / instagram.js
Last active Oct 4, 2019
Instagram Graph API Media
View instagram.js
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 Sep 9, 2019
The simplest way to generate a private key and self-signed certificate for localhost.
View localhost.sh
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 Sep 10, 2019
DNS over HTTPS (DoH) in Google Chrome
View .aliases
# 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 Sep 11, 2019
Best-Practice Docker Image and GitHub Workflow for Node.js app. [Continuous Integration/Delivery/Deployment]
View Dockerfile
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 . .
View Dockerfile
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
View ecosystem.config.js
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,
You can’t perform that action at this time.