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
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 / delay.js
Created Dec 16, 2016
Node.js Async/Await delay
View delay.js
'use strict'
const timeout = ms => new Promise(res => setTimeout(res, ms))
function convinceMe (convince) {
let unixTime = Math.round(+new Date() / 1000)
console.log(`Delay ${convince} at ${unixTime}`)
}
async function delay () {
@daliborgogic
daliborgogic / .dockerignore
Last active Oct 9, 2019
Mnml Nuxt.js Docker ~57.5MB
View .dockerignore
*
!assets
!pages
!static
!nuxt.config.js
!package-lock.json
!package.json
@daliborgogic
daliborgogic / github.js
Last active Oct 7, 2019
Request a user's GitHub identity
View github.js
const uuid = require('uuid')
const {
GITHUB_CLIENT_ID = '#####',
GITHUB_REDIRECT_URL = 'https://example.com/callback',
GITHUB_SCOPE = 'user:email'
} = process.env
const authorize = `https://github.com/login/oauth/authorize`
const states = []
@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 / default.vue
Last active Sep 28, 2019
Vantablack? Nuxt.js simple theme switch
View default.vue
<script>
export default {
computed: {
theme () {
const [color, backgroundColor] = this.$store.state.theme
return {
'--color': color,
'--background-color': backgroundColor
}
}
@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 . .
@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 / 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")
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
You can’t perform that action at this time.