Skip to content

Instantly share code, notes, and snippets.

View MatissJanis's full-sized avatar
❤️
Loving frontend development

Matiss Janis Aboltins MatissJanis

❤️
Loving frontend development
View GitHub Profile
interface EntityStateModel<T> {
entities: Record<string, T>;
ids: string[];
}
@MatissJanis
MatissJanis / integration-test.spec.js
Created April 23, 2020 19:41
Example unit & integration test
import { mount } from 'enzyme';
import MyComponent from './MyComponent';
describe('MyComponent', () => {
/**
* Important: notice how integration tests use `mount` to mount not
* just this component, but it's children as well. Hence we can test
* full customer journeys here (with external systems - APIs - still
* being mocked).

Keybase proof

I hereby claim:

  • I am MatissJanis on github.
  • I am mja (https://keybase.io/mja) on keybase.
  • I have a public key whose fingerprint is BD9C AC67 7471 0129 0FF6 43B3 5D1A 9122 328E 8B2D

To claim this, I am signing this object:

@MatissJanis
MatissJanis / laravel-email-errors.php
Last active June 24, 2021 14:46
Laravel: Email admin if an error occured
<?php
/**
* Email an administrator if an error occured
*/
Event::listen('illuminate.log', function($level, $message, $context) {
if (in_array($level, ['error', 'critical', 'emergency', 'alert']) == false)
return;
Mail::raw((string) $message, function($mail) use ($level, $message) {
$mail->to('foo@bar.com', 'Admin');
$mail->subject(sprintf('[%s] Error: %s', $level, $message->getMessage()));
@MatissJanis
MatissJanis / translate-titles.php
Last active April 16, 2022 18:25
OctoberCMS snippets; tips and tricks
<?php
// Listen for page titles and parse them through the translate plugin
Event::listen('cms.page.init', function($controller, $page) {
$messageIds = [$page->title, $page->seo_title];
if (isset($page->apiBag['staticPage']))
{
$vars = $page->apiBag['staticPage']->getViewBag();
$messageIds[] = $vars->property('seo_title');
$vars->setProperty('seo_title', Message::get($vars->property('seo_title')));