Skip to content

Instantly share code, notes, and snippets.

View bojanz's full-sized avatar

Bojan Zivanovic bojanz

View GitHub Profile
@bojanz
bojanz / bench_test.go
Created January 21, 2022 17:58
bojanz/currency benchmark
View bench_test.go
package currency_test
import (
"testing"
"github.com/bojanz/currency"
)
var result currency.Amount
var cmpResult int
@bojanz
bojanz / responsetest.go
Last active March 6, 2023 09:58
OpenAPI assert helper
View responsetest.go
package responsetest
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"github.com/getkin/kin-openapi/openapi3"
"github.com/getkin/kin-openapi/openapi3filter"
@bojanz
bojanz / CustomerProfile.php
Created December 21, 2018 01:05
Addressbook 2.x UX
View CustomerProfile.php
<?php
namespace Drupal\commerce_order\Plugin\Commerce\InlineForm;
use Drupal\commerce\EntityHelper;
use Drupal\commerce\Plugin\Commerce\InlineForm\EntityInlineFormBase;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\EntityTypeManagerInterface;
@bojanz
bojanz / generate_currencies.php
Last active June 27, 2017 11:48
Script for regenerating Commerce 1.x currencies based on CLDR
View generate_currencies.php
<?php
/**
* Regenerates the Commerce 1.x currency list from CLDR.
*
* Assumes the existence of commerce/ and intl/ folders.
* The intl/ folder should contain the commerceguys/intl
* library with the CLDR dataset downloaded via
* scripts/fetch_data.sh
*/
View .vimrc
color pt_black
syntax enable
set nowrap
set wildmenu
set lazyredraw
set showmatch
set incsearch
set hlsearch
View keybase.md

Keybase proof

I hereby claim:

  • I am bojanz on github.
  • I am bojanz (https://keybase.io/bojanz) on keybase.
  • I have a public key whose fingerprint is 44A5 A3CC 1569 CD18 1863 8732 6FC5 55AF 7DB3 3E13

To claim this, I am signing this object:

@bojanz
bojanz / extension-patterns.md
Last active January 14, 2023 16:59
Extension patterns: events, tagged services, plugins
View extension-patterns.md

This documentation is destined for drupal.org. Created first as a gist to make initial comments easier. Rewrites and clarifications welcome. Code samples are simplified for clarity. Perhaps a bit too much?

When talking about extensibility, there are several distinct use cases:

  1. Reacting to an action that has already happened.

The reaction can be anything; outputting a message, sending an email, modifying a related object, etc. Examples:

  • "A node has been saved"
  • "A product has been added to the cart".