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 / gutenvue.js
Last active August 19, 2024 18:07
Gutenberg Block built with Vue.js
// https://wordpress.org/gutenberg/
(wp => {
const el = wp.element.createElement
const __ = wp.i18n.__
wp.blocks.registerBlockType( 'plugins/gutenvue', {
title: __('Gutenberg: VueJS', 'gutenvue'),
category: 'widgets',
supportHTML: false,
attributes: {
@daliborgogic
daliborgogic / gist:ae3e8a5cf6a50d7ab096d5ad3f901829
Last active September 3, 2018 14:00
Set environment variables from file
$ cat > .env << EOL
foo=foo
foobar="foo bar"
EOL

$ env grep -v '^#' .env | xargs -d '\n' -t
echo  foo=foo foobar="foo bar" 
env: ‘bar"’: No such file or directory
function notify_post ($post_id) {
$request = new WP_REST_Request('GET', '/wp/v2/posts/' . $post_id);
$response = rest_do_request($request);
$status = $response->get_status();
$data = $response->get_data();
$callback_uri = 'https://example.com';
wp_safe_remote_post($callback_uri, array('body' => json_encode($data)));
}
add_action('post_updated', 'notify_post');
@daliborgogic
daliborgogic / H1.vue
Last active September 11, 2018 11:37
<template lang="pug">
h1(v-html="content")
</template>
<script>
export default {
props: {
content: {
type: String,
default: ''
@daliborgogic
daliborgogic / Content.vue
Last active November 6, 2019 12:35
Mark external links (UX). internal let router handle.
<template>
<div v-html="content" />
</template>
<script>
export default {
props: {
content: {
type: String,
default: ''
@babel
@csstools
@nuxtjs
@vue
@webassemblyjs
@xtuc
accepts
acorn
acorn-dynamic-import
ajv
@daliborgogic
daliborgogic / .dockerignore
Last active December 22, 2019 08:16
Mnml Nuxt.js Docker ~57.5MB
*
!assets
!pages
!static
!nuxt.config.js
!package*.json
@daliborgogic
daliborgogic / Dockerfile
Last active September 15, 2018 17:35
DevOops Multi Stage Build
FROM mhart/alpine-node:10.10.0 as full
WORKDIR /app
ENV HOST 0.0.0.0
COPY . .
RUN npm ci
RUN npm run build
RUN rm -rf node_modules
# Magic!
RUN npm ci nuxt-start-edge debug --production
@daliborgogic
daliborgogic / workers.js
Last active September 18, 2018 15:52
Web Workers Example
const marked = require('marked')
self.onmessage = function (event) {
switch (event.data) {
case 'next':
next(event.data)
break
case 'license':
license(event.data)
break