Skip to content

Instantly share code, notes, and snippets.

@yikuansun
yikuansun / addImageSync.js
Created February 24, 2024 23:16
Add image to document synchronously in Photopea
let currentDocument = app.activeDocument;
/*
load in the image as an array buffer - will open in new document
*/
app.activeDocument.activeLayer.copy(true);
app.activeDocument.close();
app.activeDocument = currentDocument;
let newLayer = currentDocument.layers.add();
currentDocument.paste();
@yikuansun
yikuansun / addImageAndWait.js
Last active February 21, 2024 13:46
Useful algorithms for Photopea plugin development
// uses Photopea.js
var addImageAndWait = async function(contentWindow, imgURI) {
return new Promise(async function(resolve) {
var layerCountOld = "done";
while (layerCountOld == "done") layerCountOld = (await Photopea.runScript(contentWindow, `app.echoToOE(app.activeDocument.layers.length)`))[0];
var layerCountNew = layerCountOld;
await Photopea.runScript(contentWindow, `app.open("${imgURI}", null, true);`);
var layerCheckInterval = async function () {
layerCountNew = (await Photopea.runScript(contentWindow, `app.echoToOE(app.activeDocument.layers.length)`))[0];
if (layerCountNew == layerCountOld + 1) {
<?php
namespace Famelo\Template\ViewHelpers;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
* TYPO3 is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License version 2 as published by *
* the Free Software Foundation. *
* *
@Torsten85
Torsten85 / PagePreviewRenderer.php
Created November 26, 2015 08:10
Showing the preview section of fluidpages.
<?php
namespace My\Extension\Hooks;
use FluidTYPO3\Fluidpages\Provider\PageProvider;
use TYPO3\CMS\Backend\Controller\PageLayoutController;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;
use FluidTYPO3\Flux\View\PreviewView;
@NamelessCoder
NamelessCoder / content-page-vision.md
Last active January 10, 2018 08:04
My vision for TYPO3 content/page integrations

My vision for TYPO3 content/page integrations

Estimated 15 minute read

Continuing from my vision for Fluid I'd like to describe another vision related to it. Where the first article is mainly about what we could do with the Fluid template engine outside of TYPO3, this article focuses on what we can do with it in TYPO3. It assumes the previous vision was realised.

The vision can be summarised as follows:

We should have a way to drop-in replace and add content templates, instead of requiring massive amounts of boilerplate configuration/code. And we should have a method for managing nested content which is provided by the core itself.

@ambroisemaupate
ambroisemaupate / security.conf
Last active October 14, 2024 07:59
Nginx CSP example
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
@pixelbrackets
pixelbrackets / homepage.html
Last active August 29, 2015 14:13
Allow/Deny Content Elements in FLUX grids
<!-- Allow ONLY the FCE »Slider« in a column -->
<flux:grid>
<flux:grid.row>
<flux:grid.column name="sliderContent" colPos="1" variables="{allowedContentTypes: 'fluidcontent_content', Fluidcontent: {allowedContentTypes: 'Vendorname.some_extension_key:Slider.html'}}" />
</flux:grid.row>
<flux:grid.row>
<flux:grid.column name="mainContent" colPos="0" variables="{Fluidcontent: {deniedContentTypes: 'Vendorname.some_extension_key:Slider.html'}}" />
</flux:grid.row>
</flux:grid>
@tv-schulz
tv-schulz / Default.html
Created November 17, 2014 14:41
One Pager Rendering VHS
<v:page.menu entryLevel="0" levels="1" expandAll="FALSE" as="subpages">
<f:for each="{subpages}" as="subpage">
{subpage.uid -> v:variable.register.set(name: 'subpage')}
<v:render.request action="render" controller="Page" arguments="{page:subpage}" pageUid="{subpage.uid}" extensionName="ExtKey" vendorName="Vendor" />
</f:for>
</v:page.menu>
@irnnr
irnnr / README.md
Last active October 2, 2015 02:14
TYPO3 Dynamic Return Type code completion
@NamelessCoder
NamelessCoder / MyModel.php
Last active November 25, 2015 14:02
Example of using annotations to generate TCA configuration based on a Model class.
<?php
namespace FluidTYPO3\Demo\Domain\Model;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* Domain Model: Simple entry with tag relations.
*
* The annotations on the class-level doc comment define