Skip to content

Instantly share code, notes, and snippets.

Jani Tarvainen janit

View GitHub Profile
View swiftmailer.yaml
// YAML config for sending emails on eZ Platform Cloud / on eZ Platform v3.0 and higher
url: 'smtp://%env(PLATFORM_SMTP_HOST)%'
spool: { type: 'memory' }
View clean-up-ezp-31546-issue.txt
eZ Platform v3.0.0 used ezplatform-kernel 1.0.0 package which had an issue with
storing images in the wrong directory:
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 / preparerichtext.php
Last active Jun 20, 2019
Convert HTML to eZ Platform Rich Text DocBook XML format
View preparerichtext.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 / init.txt
Last active Jun 15, 2018
Using Zyxel SBG3300 with CDC ethernet on Huawei E5377 (eth3G)
View init.txt
# You can run the Huawei E5377 LTE modem as an ethernet device on the Zyxel SBG3300 router
# More here:!gwsViewDetail.action?articleOid=013274&lang=EN
Short info:
$ telnet
$ sh
$ usb_modeswitch -v 12d1 -p 1f02 -V 4817 -P 5340 -M 55534243123456780000000000000a11062000000000000100000000000000
$ lsusb
janit / sw.js
Last active Oct 31, 2019
Service Worker example for controlling what is cached - See
View sw.js
self.addEventListener('install', function (event) {
var preLoad = function () {
// console.log('[PWA Builder] Install Event processing');
return'pwabuilder-offline').then(function (cache) {
// console.log('[PWA Builder] Cached index and offline page during Install');
return cache.addAll(['/offline.html', '/']);
janit /
Created Jun 26, 2017
Rotating PostgreSQL Backup Script
# for use with cron, eg:
# 0 3 * * * postgres /var/db/ foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
View DefaultController.php
public function apiApartmentsAction(Request $request)
$appState = new AppState();
$em = $this->get('doctrine.orm.default_entity_manager');
$apartments = $em->getRepository('AppBundle:Apartment')->getRandom(10);
$response = new JsonResponse();
View app.js
var ApartmentListing = Vue.extend({
template: `
<h2>Hello from Vue</h2>
<tr v-for="apartment in apartments">
{{ apartment.streetaddress }}<br />
{{ }}<br />
{{ apartment.zipcode }}
View base.html.twig
<script type="text/javascript">
var initialAppState = {{ appstate_serialized|raw }};
<script src="{{ asset('bundles/app/js/vue/vue.js') }}"></script>
<script src="{{ asset('bundles/app/js/vue/app.js') }}"></script>
View index.html.twig
<h2>Hello from Twig</h2>
{% for apartment in %}
{{ apartment.streetaddress }}<br />
{{ }}<br />
{{ apartment.zipcode }}
<td>{{ }}</td>
You can’t perform that action at this time.