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 / service-worker-dev.js
Created June 22, 2017 16:49
Service worker dev
// This service worker file is effectively a 'no-op' that will reset any
// previous service worker registered for the same host:port combination.
// In the production build, this file is replaced with an actual service worker
// file that will precache your site's local assets.
// See https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432
self.addEventListener('install', () => self.skipWaiting())
self.addEventListener('activate', () => {
self.clients.matchAll({ type: 'window' }).then(windowClients => {
@daliborgogic
daliborgogic / App.vue
Last active September 3, 2018 22:39
Notify when caching is complete or new or updated content is available
<script>
mounted () {
window.addEventListener('online', () =>
store.dispatch('snackbar', { id: 0, show: false })
)
window.addEventListener('offline', () =>
store.dispatch('snackbar', { id: 0, show: true })
)
@daliborgogic
daliborgogic / entry-client.js
Last active July 1, 2019 09:51
Vue.js SPA Google Analytics
// https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
)
@daliborgogic
daliborgogic / gist:f5603e178b7d9d8a50843e8471dcf8f6
Created May 31, 2017 20:11
Native string.padStart() and string.padEnd()
$ node -v
> v8.0.0
$ node
> let codeName = 'carbon'
undefined
> codeName.padStart(10)
' carbon'
> codeName.padEnd(10)
'carbon '
@daliborgogic
daliborgogic / shot.sh
Created May 1, 2017 20:24
Headless Chrome Taking screenshots
# https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
# --disable-gpu currently required, see link above
google-chrome --headless --screenshot --disable-gpu --window-size=1440,900 https://daliborgogic.com/
@daliborgogic
daliborgogic / install-postman.sh
Last active April 28, 2017 21:50 — forked from pierremonico/Postman.desktop
Install Postman
#!/bin/bash
cd /tmp || exit
echo "Downloading Postman ..."
wget -q https://dl.pstmn.io/download/latest/linux?arch=64 -O postman.tar.gz
tar -xzf postman.tar.gz
rm postman.tar.gz
echo "Installing to opt..."
if [ -d "/opt/Postman" ];then
sudo rm -rf /opt/Postman
@daliborgogic
daliborgogic / index.js
Last active February 12, 2017 14:32
Input-specific event handling by using a single pointer event you can use the pointerType property
// https://w3c.github.io/pointerevents/
foo.addEventListener('pointerdown', e => {
switch (e.pointerType) {
case 'mouse':
// mouse detected
break
case 'pen':
// pen / stylus detected
break;
@daliborgogic
daliborgogic / index.pug
Last active May 10, 2020 07:30
Product Social Media Tags
//- https://search.google.com/structured-data/testing-tool#url=daliborgogic.com
//- https://cards-dev.twitter.com/validator
//- https://developers.facebook.com/tools/debug/
html(itemscope itemtype="http://schema.org/Product")
title Page Title. Maximum length 60-70 characters
meta(name="description" content="Page description. No longer than 155 characters.")
//- Schema.org markup for Google+
@daliborgogic
daliborgogic / Terminal.sublime-settings
Last active February 3, 2017 16:44
Launch Hyperterm from the current file or the root project folder
// https://packagecontrol.io/packages/Terminal
{
"terminal": "/opt/Hyper/hyper",
"parameters": ["%CWD%"]
}
@daliborgogic
daliborgogic / Dockerfile
Created January 29, 2017 17:31
Alpine with dependencies that rely on node-gyp
FROM node:alpine
RUN apk add --no-cache --virtual .gyp \
python \
make \
g++ \
&& npm install \
[ your npm dependencies here ] \
&& apk del .gyp