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
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 / 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
@daliborgogic
daliborgogic / gutenvue.js
Last active December 18, 2025 16:12
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: {
alias headers='curl -I -s -X GET'
@daliborgogic
daliborgogic / functional.mjs
Last active July 22, 2018 14:13
Functional JavaScript [idiomatic]
// Array utils /////////////////////////////////////////////////////////////////
export const combine = (...arrays) => [].concat(...arrays)
export const compact = arr => arr.filter(Boolean)
export const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
)()
@daliborgogic
daliborgogic / index.js
Last active July 13, 2018 19:32
Asynchronous HTTP2 microservice example
const h2 = require('http2')
const { run, send } = require('micro')
const cert = require('openssl-self-signed-certificate')
const { PORT = 3443 } = process.env
const options = {
key: cert.key,
cert: cert.cert,
passphrase: cert.passphrase
}
@daliborgogic
daliborgogic / reset.code-snippets
Last active July 8, 2018 17:01
Reduce browser inconsistencies
{
"Reset": {
"prefix": "reset",
"scope": "stylus",
"body": [
"*",
"*::before",
"*::after",
" box-sizing border-box",
"",
@daliborgogic
daliborgogic / index.js
Created June 22, 2018 22:04
Micro serve
const url = require('url')
const fs = require('fs')
const path = require('path')
const { send } = require('micro')
const mime = require('mime')
module.exports = async (req, res) => {
const parseUrl = url.parse(req.url)
let file = `.${parseUrl.pathname}`
@daliborgogic
daliborgogic / nginx-geoip-module.md
Created June 12, 2018 13:44 — forked from VirtuBox/nginx-geoip-module.md
How to configure GeoIP module for Nginx

Create a folder to store the databases :

mkdir -p /usr/share/GeoIP

Download Country IP database

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
@daliborgogic
daliborgogic / .bash_aliases
Last active April 6, 2018 12:09
bash docker compose
if [ -f ~/.bash_docker_compose ]; then
. ~/.bash_docker_compose
fi