Skip to content

Instantly share code, notes, and snippets.

View tomazzaman's full-sized avatar

Tomaž Zaman tomazzaman

  • Mono Technologies Inc.
  • Slovenia
View GitHub Profile
@tomazzaman
tomazzaman / README.md
Last active October 29, 2025 15:29
Intro to Yocto I wish I was given | Part 1: The Basics

The files we need to build a basic root filesystem with Yocto. These are the support files for a YouTube video

@tomazzaman
tomazzaman / README.md
Created October 29, 2025 13:26
Intro to Yocto I wish I was given | Part 2: The Kernel

This are the files from the second video, so make sure to first grab files from the first one, since here we're just listing the updated and new files.

@tomazzaman
tomazzaman / resolver.sh
Created January 2, 2025 17:39
Automatically add hostnames to Pihole whenever containers get updated
#!/bin/sh
#
# Update Pihole's custom.list based on the "hostname" property of a container.
#
# Environment variables
# - OVERRIDE_IP sets the IP of the container in Pihole's DNS records. Defaults to container IP in Docker network.
# - DOMAIN_FILTER only triggers the updates on a match. If empty, it'll always update the records file.
# - PIHOLE_CUSTOM_LIST_FILE /etc/hosts compatible DNS records file in format "IP hostname".
# - PIHOLE_CONTAINER_NAME because we need to reload Pihole's internal resolver when making changes
#
@tomazzaman
tomazzaman / class-watermark-image.php
Created April 7, 2015 19:30
Watermarking uploads in WordPress with Imagemagick
function register_watermarked_size() {
add_image_size( 'watermarked', 550, 550, true ); // This is what should be uploaded
}
add_action( 'init', 'register_watermarked_size' );
class Watermark_Image {
// The attachment meta array
public $meta = array();
@tomazzaman
tomazzaman / class-developer-import.php
Created March 31, 2015 18:03
Import JSON into WordPress
<?php
// Published under GPL
// tutorial here: https://codeable.io/community/how-to-import-json-into-wordpress/
class Developer_Import {
public function __construct() {
add_action( 'wp_ajax_import_developer', array( $this, 'import_developer' ) );
@tomazzaman
tomazzaman / generateSVG.js
Created January 16, 2016 19:33
Generate PNG from a React-powered SVG. Server-side.
/**
* Run this with `babel-node generateSVG.js`
*/
import fs from 'fs';
import path from 'path';
import { Readable } from 'stream';
import childProcess from 'child_process';
import phantomjs from 'phantomjs';
import im from 'imagemagick';
import tmp from 'tmp';
@tomazzaman
tomazzaman / README.md
Last active April 19, 2024 17:01
Kill supervisor on Docker when any of the services fail

Killing supervisor if any of it's child processes fail

The trick is to only register the listener for events that indicate failure, namely

  • PROCESS_STATE_STOPPED
  • PROCESS_STATE_EXITED
  • PROCESS_STATE_FATAL

Once they do, we should send a SIGQUIT to Supervisor.

@tomazzaman
tomazzaman / README.md
Last active September 17, 2023 20:59
Gulp workflow for WordPress theme development

Gulp workflow for WordPress theme development

Requirements

In order for Livereload to work, you need a Firefox or Chrome extension as Gulp doesn't inset it automatically. Alternatively, you can also manually put the livereload script in footer.php, just make sure to insert it only on development environment:

<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
@tomazzaman
tomazzaman / README.md
Created May 24, 2023 19:58
Simple Active Storage direct upload form with a Stimulus controller

Title pretty much sums it up. I wanted it to support drag and drop as well, which is why the .droparea is positioned absolutely; It's below the input field and the field itself gets its opacity set to 0, for better UX experience.

@tomazzaman
tomazzaman / pushover.sh
Created September 11, 2022 10:41
Messaging script for pushover.net
#!/usr/bin/env bash
# Messaging script for pushover.net (make sure you have an account)
# put this somewhere in your $PATH and make it executable
if [ $# -eq 0 ]; then
echo "Usage: pushover <title> <message>"
echo "Example: $ pushover \"This is the title\" \"This is a nice message\""
exit
fi