Skip to content

Instantly share code, notes, and snippets.

View janit's full-sized avatar

Jani Tarvainen janit

View GitHub Profile
public static function riotRenderer($tagName,$coords) {
$buffer = '<!-- begin riot: ' . $tagName . ' -->' . PHP_EOL;
$tagFile = '../web/js/tags/' . $tagName . '.tag';
$processCommand = 'node ../renderer/app.js ' . $tagFile . ' ' . $coords[0] . ' ' . $coords[1];
$process = new Process($processCommand);
$process->run();
if (!$process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}
$buffer .= $process->getOutput();
@janit
janit / index.html.twig
Created September 13, 2015 10:41
Twigriot 4
<h1>Yandex Map Riot.js Component rendered via Twig</h1>
{{ riot_render('ymap',coords) }}
@janit
janit / index.html
Created September 13, 2015 10:41
Twigriot 5
<h1>Yandex Map Riot.js Component rendered via Twig</h1>
<!-- begin riot: ymap -->
<ymap><div id="ymap"></div> <script src="https://api-maps.yandex.ru/2.0-stable/?load=package.full&amp;lang=en-US" type="text/javascript"></script></ymap>
<script src="/js/tags/ymap.js"></script>
<!-- end riot -->
@janit
janit / images.php
Last active October 4, 2015 17:01
images.php
<?php
$app->get('/images'), function () use ($app) {
$images = array('/images/1.jpg','/images/2.jpg','/images/3.jpg');
$response = new JsonResponse($images);
return $response;
});
@janit
janit / images2.php
Last active October 4, 2015 17:00
images2.php
<?php
$app->get('/images'), function () use ($app) {
$images = array('/images/1.jpg','/images/2.jpg','/images/3.jpg');
$response = new JsonResponse($images);
foreach($images as $image){
$response->headers->set('link','<' . $image . '>; rel=preload; as=image',false);
  }
 
@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 / searchapiexample.php
Last active November 2, 2015 13:53
eZ Publish search api example
<?php
$contentTypes = array('article','blog_post');
$contentTypes = array('eng-GB','fin-FI');
$locationPath = '/2/30/44';
$query = new Query();
$query->filter = new Criterion\LogicalAnd(
array(
new Criterion\ContentTypeIdentifier($contentTypes),
@janit
janit / dhtml.jsx
Last active December 20, 2015 09:59
import React, { Component } from 'react'
import useSheet from 'react-jss'
// You can use jss directly too!
import jss from 'jss'
import vendorPrefixer from 'jss-vendor-prefixer'
jss.use(vendorPrefixer)
const styles = {
button: {
<DIV ID="controls">
<FORM>
<INPUT TYPE="button" VALUE="Toggle font change" ONCLICK="toggle_fontsize()">
<INPUT TYPE="button" VALUE="Toggle colorcycle" ONCLICK="toggle_color()">
<INPUT TYPE="button" VALUE="Toggle sinus" ONCLICK="toggle_sinus()">
<INPUT TYPE="button" VALUE="Toggle scrolling" ONCLICK="toggle_scroller()"><BR>
<INPUT TYPE="button" VALUE="Toggle colorfader" ONCLICK="toggle_fade()"> (only with font changer on, disables colorcycle)
</FORM>
</DIV>
@janit
janit / scroller.js
Last active December 20, 2015 10:24
// default values for the toggles
var changefont = false;
var colorchanger = false;
var colorfade = false;
var dosinus = true;
// global variables and temporary settings, brrrhhh
var xtmp=0;var msgtmp=0;var doscroll=false;var scrollcount=0;var linecount=0;var runcount=0;var colorcount=0;var font=15;var dir2='up'; var msg=new Array();var controls=false;
// the toggles, needed only for this demo page