Skip to content

Instantly share code, notes, and snippets.

@netcarver
netcarver / TitlecaseNamedEntities.py
Last active October 18, 2021 06:35
Custom Rasa NLU Pipeline Component
# -*- coding: utf-8 -*-
from rasa_nlu.components import Component
"""
About
-----
The Spacy tokenizer uses lowercase by default, so training an NLU model using
@netcarver
netcarver / escrow.md
Last active July 10, 2020 16:19
Threadsafe counters markdown files.

The Great Shopping Race

Have you ever been in a shop during the new-year sales? There can be a lot of demand for a limited number of physical products but there can never be more items on the shelves and in shopping baskets than the actual physical number of items there were for sale in the first place as the atoms of the items themselves prevent duplication.

It's not quite the same for virtual shops; there are no physical products in the webserver - just bits representing them. By careful programming we have to provide safeguards against race conditions ourselves. Threadsafe counters provides one method for doing this based on an escrow model in which sales are not a 2-state affair (available or sold)

@netcarver
netcarver / contact.php
Created April 30, 2012 19:11
Simple contact form for PW. Depends on flourish by Will Bond.
<?php
include('head.inc'); // Include your head setup.
/* Setup the flourish class autoloader. */
function flourish_loader( $class_name )
{
// ** Customize this to your root Flourish directory **
$flourish_root = wire('config')->paths->root . 'site/.flourish/';
$contact_form = Form('ao2', './')
->setRenderer( $r ) // Tells the form which renderer to use to generate its output.
//->_show_submitted(true) // Causes the form to show submitted values
//->_show_html(true) // Causes the form's renderer to expose the generated HTML for the form.
//->_show_form_elements(true) // Causes the form to show its internal structure
//->_show_form_errors(true)
//->match('myContactFormValidator') // Adds a validator to the form. You can use a form-level validator to add complex inter-item validation.
->onSuccess('MySuccessHandler')
->novalidate() // Stop FF doing client-side evaluation whilst testing.
<?php
include($config->paths->root . "site/.libs/countries/countryList.class.php");
$ct = new CountryList();
$countries = $ct->getCountryList($lang);
$show_form = true;
$note = '<h3>Danke!</h3>';
$errors = '';
@netcarver
netcarver / flourishLoad.php
Created March 26, 2012 17:53
Flourish autoloader for ProcessWire
<?php
function flourish_loader( $class_name )
{
// Customize this to your root Flourish directory
$flourish_root = $_SERVER['DOCUMENT_ROOT'] . 'site/.flourish/';
$file = $flourish_root . $class_name . '.php';
if (file_exists($file)) {
@netcarver
netcarver / sed_cleaner.txt
Created August 11, 2011 21:47
sed_cleaner -- with trigger guard.
# Name : sed_cleaner
# Version : 0.8.45
# Description : Does a little house cleaning on new installs.
# Author : Netcarver
# URL : https://github.com/netcarver/sed_cleaner
# Type : Admin only
# ......................................................................
# Revision : 08ad0b362fbe0908f8adaaaaf09f0863a76cbed5
# Branch : master
# ......................................................................
@netcarver
netcarver / sed_admin_log.txt
Created August 9, 2011 00:45
sed_admin_log Txp plugin (compiled)
# Name : sed_admin_log
# Version : 0.1.1
# Description : Provides an admin audit trail.
# Author : Netcarver
# URL : https://github.com/netcarver/
# Type : Admin only
# ......................................................................
# Revision :
# Branch :
# ......................................................................
@netcarver
netcarver / sed_default_article_status.txt
Created August 7, 2011 20:56
sed_default_article_status
# Name : sed_default_article_status
# Version : 0.4.1.12
# Description : Makes the Draft article status default.
# Author : Stef Dawson, Destry Wion & Netcarver
# URL : http://forum.textpattern.com/viewtopic.php?pid=249855#p249855
# Type : Admin only
# ......................................................................
# Revision : 015ab92387002978ee025a54fae864c0aa4e1f72
# Branch : master
# ......................................................................
@netcarver
netcarver / hhh_textile_title_v0.2.1.txt
Created February 8, 2011 19:45
Updated v0.2 to work with textile 2.2
# Name: hhh_textile_title v0.2.1
# Type: Public side plugin
# Textile-enabled replacement for <txp:title />
# Author: Jan Holeček
# URL: http://www.fi.muni.cz/~xholecek
# Recommended load order: 5
# .....................................................................
# This is a plugin for Textpattern - http://textpattern.com/
# To install: textpattern > admin > plugins