Skip to content

Instantly share code, notes, and snippets.

View janit's full-sized avatar

Jani Tarvainen janit

View GitHub Profile
@janit
janit / preparerichtext.php
Last active February 6, 2024 11:52
Convert HTML to eZ Platform Rich Text DocBook XML format
<?php
// This is the namespace you want to use
use EzSystems\EzPlatformRichText\eZ\FieldType\RichText\Type as RichTextFieldType;
// this would be a method in your class (you'll need to inject RichTextFieldType)
// It has some extra wrangling of input not required, but makes it moarrr robust
private function prepareRichText($inputText){
if($inputText === ''){
@janit
janit / db_backup.sh
Created June 26, 2017 06:15
Rotating PostgreSQL Backup Script
#!/bin/bash
# for use with cron, eg:
# 0 3 * * * postgres /var/db/db_backup.sh foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
fi

Keybase proof

I hereby claim:

  • I am janit on github.
  • I am janit (https://keybase.io/janit) on keybase.
  • I have a public key ASAVpmR_PpgT0putmX8REETDu2wYOegUUqL5Mq_pWcmb4wo

To claim this, I am signing this object:

@janit
janit / ezpublish.yml
Last active February 18, 2021 16:24
## Configure db connections ##
doctrine:
dbal:
connections:
repo_one_connection:
driver: pdo_mysql
host: localhost
user: repo_one
password: foo
dbname: repo_one
@janit
janit / gist:08db57c88017a8937ba3bfc107f55aa5
Created January 15, 2021 14:02
Powercycle UniFi PoE Port via adi using node.js
// https://www.npmjs.com/package/node-unifi
var unifi = require('node-unifi');
var controller = new unifi.Controller("CONTROLLER_IP_HERE", 8443);
// LOGIN
controller.login("YOUR_USER_HERE", "YOUR_PASSWORD_HERE", function(err) {
if(err) {
console.log('ERROR: ' + err);
@janit
janit / 1_readme.md
Last active November 19, 2020 09:21
Benchmark of eZ Platform EE 2.5.15 install on Composer 1.10 and 2.0

Recently I did a round of benchmark on the performance and memory implications for an install of Ibexa Experience. You can find this article with some analysis of results here: Benchmarks of Composer 2.0 vs 1.10 with Ibexa DXP

Björn Köster was interested in if I had did any tests for eZ Platform EE 2.5. I had not, but have now. Similar to with Ibexa DXP, the improvements are significant on 2.0. Scripts used for this (single) benchmark are in other files. See raw results below.

------8<------------------8<------------------8<------------------8<------------------8<------------

Composer 1.10:

@janit
janit / 1_main.sh
Last active November 19, 2020 08:09
Benchmarking Composer 2.0 and 1.10
composer selfupdate --2
sleep 10
./benchmark.sh
cp results.txt 2_0-1.txt
sleep 60
./benchmark.sh
cp results.txt 2_0-2.txt
// YAML config for sending emails on eZ Platform Cloud / Platform.sh on eZ Platform v3.0 and higher
swiftmailer:
url: 'smtp://%env(PLATFORM_SMTP_HOST)%'
spool: { type: 'memory' }
eZ Platform v3.0.0 used ezplatform-kernel 1.0.0 package which had an issue with
storing images in the wrong directory: https://jira.ez.no/browse/EZP-31546
The issue was fixed in ezplatform-kernel 1.0.1 (shipped in eZ Platform v3.0.1),
but misplaced files and corrupt database entries for image binaries remain in
the wrong location. This will make your installation not work consistently.
This is a set of commands that can be used to remedy the issue and bring your
file structure and database up-to-date if you have been running version 3.0.0
@janit
janit / sw.js
Last active October 31, 2019 11:26
Service Worker example for controlling what is cached - See https://malloc.fi/fix-duplicate-redirects-service-worker-caching
self.addEventListener('install', function (event) {
event.waitUntil(preLoad());
});
var preLoad = function () {
// console.log('[PWA Builder] Install Event processing');
return caches.open('pwabuilder-offline').then(function (cache) {
// console.log('[PWA Builder] Cached index and offline page during Install');
return cache.addAll(['/offline.html', '/']);
});