Skip to content

Instantly share code, notes, and snippets.

View bseddon's full-sized avatar
💭
Working hard on XBRL and XAdES signing

Bill Seddon bseddon

💭
Working hard on XBRL and XAdES signing
  • Lyquidity Solutions Limited
View GitHub Profile
@bseddon
bseddon / wp-theme.md
Last active January 24, 2024 01:15
Different WordPress theme by users

When developing a large application in WordPress one option is to implement it as a theme rather than a series of plugins. When the project has multiple developers, a challenge then is how to provide each developer their own environment. If the site is standalone then each developer can have their own local WP instance. But what about the database? If different developers are adding records to different databases how are they merged.

Anyway, in my scenario there's a simpler approach. Let each developer have their own copy of the theme within the themes folder. The only requirement then is to be able to allow each user to choose or to be allocated a specific theme. This is really easy to do.

The main function is the one that reacts to the 'wp_loaded' action. The action function looks to see what theme template folder is defined in user meta for the user and returns it. Otherwise it returns a default theme folder.

The rest of the code adds a dropdown of the available themes to the user profile page

@bseddon
bseddon / why-not-react.md
Last active November 8, 2023 20:46
Why not React?

Everywhere you turn there's React. But why? Back in the day browsers were less functional and less compliant so it may have made sense for Facebook to create a tool in which their developers could work without needing to pay attention to browser differences.

I guess there are some companies for which this is still true but for many others its not. Most companies I work with use modern versions of Chrome, Edge, Safari or Fiefox. They run modern versions because the compliance functions of their organizations insist on it because they don't want an old bropwser version to be the reason they get sued for negligence after a hack.

All modern browsers are functionally complete and its hard to find a difference that has any relevance in the vast majority of cases. In my view, the case for React does not exist. It's a legacy tool that's outlived its usefulness but because Facebook uses it, it must be the right thing to use. No. React introduces a redundant run/build process so JSX can be turned into, you k

In the previous gist it was shown how to retrieve geometries in order to create SVG maps using D3. A geometry is just a sequence of latitude and longitude values for a shape. The same geomtries can be used to create overlays for Google Maps. Creating an overlay using a single array of points is covered in the Google Maps API documentation. Instead this gist covers handing multiple geomtries where the aim is to merge them so they can be shown as one continuous area.

The scenario might that you have geometries for all the counties of a state an want to use them to show the whole state. In this example, the aimn is to show the area served by the NJ Cumberland, Salem and Cape May Workforce Board. Given the name, it will no surprise that the board covers these three counties. There is no single geometry for this area but geometries for the three counties are available from the US Census Burea

@bseddon
bseddon / Mapping-using-D3.md
Last active January 26, 2023 00:43
D3 mapping example

This is not a review of all the ways D3 can be used to create maps and all the formats that can be used. It's a review of my use of D3 and how to use information within shape files published by, for example, US Census Bureau.

Let's suppose you want to create a map of all the zip codes in New Jersey and show something about each one. Here's a way to do it.

Create a folder. I'll call it 'mapping'.

Begin by downloading a source of zip codes for NJ. Copy the page of zip code and paste into Excel (drop the formatting). Delete all the columns except the one containing the zip code and so there are only zip codes then save as a CSV into the mapping folder.

Next download the Zip code tabulation areas (zctas) file and unzip again into the 'mapping' folder. The two key files are the shape file (.shp) and the database format (.dbf). T

@bseddon
bseddon / syncfusion-olap-engine.md
Created December 1, 2022 14:34
Syncfusion OLAP engine query

Syncfusion has a great JavaScript pivot table. Under the covers is support for OLAP (Analysis Services or Mondrian) not just relational or JSON or CSV. This support is implemented in a class called OlapEngine. This engine can be used separately to access data from an AS cube when there is a need to create some kind of custom report. The engine module can be imported:

import { OlapEngine } from '@syncfusion/ej2-pivotview';

Note this use of import assumes there is a script map from '@syncfusion/ej2-pivotview' to a web accessible place that implement OlapEngine.

The engine can then be used to access data:

@bseddon
bseddon / querying-with-dundas-bi.md
Last active November 17, 2022 15:16
How to create a data request in Dundas BI with selections set using view parameters

Data presented on a dashboard is mediated by one or more metric sets. A metric set defines some data set with rows and columns. A user needs only to drag a metric set onto a dashboard to begin using that data. But what happens behind the scenes? What if you want to use a metric set in code? Read on.

Get data

When the Dundas UI needs data it retrieves it using the REST API call for GetData. This REST call uses a POST request. The request body is a JSON array of one or more DataRequest objects. More about these in a moment.

If successful, the response will be an array of DataResponse objects. There should be a response object for every request object.

Request obje

@bseddon
bseddon / dbi-page-processing.md
Last active October 21, 2022 11:16
Dundas BI page rendering process

Once the page HTML is downloaded and the scripts start executing the page is created dynamically. This process is the same for all pages. The bulk of the work is done by the DBI built-in scripts especially base.js and extrastrict.js. Where these files can be found in the page is covered in the gist about the DBI page structure.

The screenshots included in this article are of the developer console in Chrome. It looks pretty much the same in Edge or Firefox or Safari.

Processing involves repreated calls to DBI REST endpoints exposed by the DBI server. This begins with a call to getsession. The server returns session information relating to the current page and user.

web-page-1

One of the bits of information in the returned object is the id of the project. This is used as a key to retrieve details of the project.

@bseddon
bseddon / dbi-page-structure.md
Last active October 21, 2022 09:07
Dundas BI pages structure

The listing below provides a canonical view of a page generated by Dundas BI. The structure of the page is the same whether it's for a frontend view or an administrator. The difference is the latter has extra files for JavaScript, CSS and localization.

The listing uses comments to describe the various sections that will appear and example tags where relevant.

There is nothing unusual about the structure used which is similar to that found in any web-based application.

From a the point of view of understanding how backend features translate into web page content, the interesting things are how items from the settings uun Setup -> app styling -> CssStyleOverride (and others like HTML Override) appear in the page content.

Note that the amount of code in the global overrides is not going to haveany material impact on the speed of page rendering for two reasons. The first is that they are static. That is, once they are read, the browser will cache the content until either the cache is removed (eg ctrl-f5)

Building the PHP ZeroMQ extension (php-zmq) for Windows

Because there is no pre-compiled PHP ZMQ extension after PHP version 7.2 it's necessary to build your own. This is a short review of the process. The PHP ZMQ extension is a wrapper around libzmq which also needs to be built. The steps needed to build libzmq are covered in another gist.

Extensions are PHP version specific as the PHP internals vary from release to release. While it's not necessary to build PHP to build an extension an extension build requires some files from the build of a version of PHP. Because its not difficult to build PHP, why not? By building a version of PHP you can build the extension at the same time.

The steps needed to build PHP are listed in the PHP SDK GitHub repository. For the purposes of this page, after following the steps the working folder will be something like:

.\php-sdk\sdk\php-8.2\vs16\x6
@bseddon
bseddon / zmq.md
Last active October 15, 2022 23:29
Building ZeroMQ on Windows

The Zero MQ extension for PHP is not available as a Windows PECL package for PHP versions later than 7.2. So for later PHP versions it's necessary to build the extension. That also means building libzmq. The Zero MQ team have dropped the Visual Studio solutions files in favour using CMake. So how do users on Windows build Zero MQ? Here's how (and it's not hard).

Install Visual Studio. While installing, opt to install C++ and make sure the option to install the CMake tools for C++ is selected.

If VS is already installed because you use it for another project type, then use the Visual Studio Installer tool (available from the start menu) to modify the installation to add C++ and the CMake tools. Note tha in Visual Studio Installer the CMake tools will appears an option in the 'individual packages' (you'll know what I mean when you get there).

Download the ZeroMQ zip from GitHub and extract it. In whatever folder you chose to extract the zip file there will be a file called CMakeFiles.txt. Edit this f