Skip to content

Instantly share code, notes, and snippets.

Jani Tarvainen janit

Block or report user

Report or block janit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 Jul 10, 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>
View DefaultController.php
public function indexAction(Request $request )
$appState = new AppState();
$em = $this->get('doctrine.orm.default_entity_manager');
$apartments = $em->getRepository('AppBundle:Apartment')->findByLimit(3);
View AppState.php
namespace AppBundle\State;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
class AppState implements \JsonSerializable {
public $fetchMore = false;
You can’t perform that action at this time.