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 / .bash_docker
Last active April 6, 2018 13:07
bash docker alias
# List containers
alias dps='docker ps'
# Fetch the logs of a container
dl() {
docker logs $1 -f
}
# Run a command in a running container
de() {
@daliborgogic
daliborgogic / zero-config-prototyping.sh
Last active July 12, 2024 22:02
"The drawback of `vue serve` is that it relies on globally installed dependencies..." Hold My 🍺
#!/usr/bin/bash
npx -p @vue/cli \
-p @vue/cli-service-global \
-p pug \
-p pug-loader \
-c "echo '<template lang="pug">
div
h1 Zero-config Prototyping
</template>' > App.vue && vue serve"
@daliborgogic
daliborgogic / sw.js
Last active January 24, 2019 16:29
sw.js
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js')
if (workbox) {
console.log(`Workbox is loaded`)
workbox.setConfig({ debug: true })
workbox.core.setLogLevel(workbox.core.LOG_LEVELS.log)
workbox.core.setCacheNameDetails({
prefix: 'localhost',
<?php
function alfa_where( $where) {
$where = str_replace("meta_key = 'tabela_$", "meta_key LIKE 'tabela_%", $where);
return $where;
}
add_filter('posts_where', 'alfa_where');
add_filter( 'rest_query_vars', function ($valid_vars) {
return array_merge($valid_vars, array(array(
@daliborgogic
daliborgogic / isType.js
Last active December 18, 2017 19:36
Check variable type
/**
* Check variable type
* @return {Boolean}
*/
export const isType = (type, val) => !!(val.constructor && val.constructor.name.toLowerCase() === type.toLowerCase())
@daliborgogic
daliborgogic / debug.vue
Last active December 17, 2017 18:43
Debug *.vue
<script>
import debug from 'debug'
const a = debug('worker:a')
const b = debug('worker:b')
export default {
mounted () {
if (process.env.NODE_ENV !== 'production') {
window.localStorage.debug = 'worker:*'
@daliborgogic
daliborgogic / Dockerfile
Last active December 3, 2017 22:54
Nuxt.js Dockerfile ~ 128MB
FROM mhart/alpine-node:base-9.2.0
WORKDIR /app
COPY . /app
ENV HOST 0.0.0.0
EXPOSE 3000
CMD ["node_modules/.bin/nuxt", "start"]
@daliborgogic
daliborgogic / ga.js
Last active June 25, 2019 17:40
Google Analytics for Nuxt.js 678bytes
export default ({ app }) => {
if (process.env.NODE_ENV !== 'production') return
const KEY = 'ga:user'
const UID = (localStorage[KEY] = localStorage[KEY] || Math.random() + '.' + Math.random())
function encode(obj) {
let k
let str = 'https://www.google-analytics.com/collect?v=1'
for (k in obj) {
@daliborgogic
daliborgogic / Dockerfile
Last active November 19, 2017 12:20
Dockerfile: 894MB
# REPOSITORY TAG IMAGE ID CREATED SIZE
# up latest 32f4569db5bc 54 seconds ago 894MB
FROM node:9.2.0-slim
RUN apt-get update && apt-get install -yq \
gconf-service \
libasound2 \
libatk1.0-0 \
libc6 \
@daliborgogic
daliborgogic / Dockerfile
Last active November 19, 2017 12:23
Dockerfile: 623MB
# REPOSITORY TAG IMAGE ID CREATED SIZE
# uptime latest 77f4f1980edc 8 hours ago 623MB
FROM node:9.2.0-slim
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV NODE_ENV production
# Install latest chrome dev package.
RUN apt-get update && apt-get install -y wget --no-install-recommends \