Skip to content

Instantly share code, notes, and snippets.

View noogen's full-sized avatar
¯\_(ツ)_/¯

Tom Noogen noogen

¯\_(ツ)_/¯
View GitHub Profile
@noogen
noogen / CpanelEmailCallback.php
Created January 30, 2024 16:54
Laravel CPanel bounce email handler as a artisan command
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
class CpanelEmailCallback extends Command
{
/**
@noogen
noogen / class-wprm-import-example.php
Last active June 9, 2021 00:25
Example elasticsearch importer for WP Recipe Maker
<?php
/**
* Responsible for importing recipes.
*
* @since 5.8.0
*
* @package Import Example
*/
/**
@noogen
noogen / viet-mong
Last active October 23, 2020 16:37
Vietnamese phonetics for Hmong language
Vietnamese phonetics for Hmong / Cách phát (phiên) âm bồi Tiếng Việt cho Tiếng H'Mông
# Consonants
- these rules denote exception to how they are pronounced in Vietnamese.
- h is silent as in hmong = mong
c, rh, ts, tx = ch
d = đ
ny = nh
r = tr (like trick)
@noogen
noogen / readline-sync-process.js
Last active July 15, 2020 15:29
Process file sync with readline
const fs = require('fs')
const readline = require('readline')
const stream = require('stream')
const {promisify} = require('util')
const got = require('got')
const pipeline = promisify(stream.pipeline)
/**
* Processing file line-by-line synchronously
@noogen
noogen / cleanup-dir.sh
Last active June 16, 2020 02:28
Cleanup Directory older than x days
#!/bin/sh
# Usage:
# ./cleanup-dir.sh /path/to/directory olderThanXDays(default=7)
EXPIRATION=${2:-7}
if [ ! -d "$1" ]; then
echo "'$1' is not a directory!"
echo "Usage:"
@noogen
noogen / wc_cart_sort.php
Last active June 1, 2020 06:47
Wordpress Cart sorting with woo-extra-product-options plugin
add_action( 'woocommerce_cart_loaded_from_session', 'sort_cart_items_alphabetically' );
function sort_cart_items_alphabetically() {
global $woocommerce;
// Read Cart Items
$products_in_cart = array();
foreach ( $woocommerce->cart->cart_contents as $key => $item ) {
// sort by title by default
@noogen
noogen / 1-spec.md
Last active January 21, 2020 16:13
Rough draft Circular API

Example

Let say you have Circulars that would rendered like so:

Booklet Example

Page Example

Note default render when there are no layout define will be 2 columns on normal screen and 1 column on mobile.

@noogen
noogen / server.conf
Last active April 25, 2019 21:32
demo-server.conf
proxy_cache_path /tmp/nginx/cache levels=1:2 keys_zone=remoteimages:10m max_size=1g inactive=45m;
server {
listen 80;
listen [::]:80 ipv6only=on;
listen 443 ssl;
listen [::]:443 ipv6only=on ssl;
ssl_certificate /etc/nginx/ssl/placeholder-fullchain.crt;
@noogen
noogen / GtinImageApi.md
Last active May 15, 2019 18:24
API Doc
@noogen
noogen / recipe.js
Last active May 19, 2021 16:33
Recipe Schema with validation rules, nutrition, and FDA recommended daily values
// based on schema.org basic recipe and nutrition definition.
// see jsonld example here: https://gist.github.com/patrickcoombe/48d4ad1eca1b22f6c5ae
// see schema markup example here: https://gist.github.com/jessotron/28f3b87d50ecb1c6aad2
// for nutrition, see: https://www.fda.gov/Food/GuidanceRegulation/GuidanceDocumentsRegulatoryInformation/LabelingNutrition/ucm385663.htm
// vitamin dv: https://www.fda.gov/Food/GuidanceRegulation/GuidanceDocumentsRegulatoryInformation/ucm535371.htm
// formula for daily value percentage is: (nutrition / recommended_dv) * 100 = dv_percentage
// reverse formula: (dv_percentage / 100) * recommended_dv = nutrition
export default {
name: 'recipe',