Skip to content

Instantly share code, notes, and snippets.

View ostark's full-sized avatar

Oliver Stark ostark

  • Berlin area, countryside
View GitHub Profile
@ostark
ostark / AppKernel.php
Last active December 23, 2015 19:29
SF2 performance tweaks for fortrabbit - /app/AppKernel.php - /app/config/config_prod.yml
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
/**
* Fortrabbit (or general NFS related) patch of Symfony AppKernel.
*
*/
class AppKernel extends Kernel
@ostark
ostark / gist:9758796
Created March 25, 2014 10:27
Disallow PHP Easter Eggs
############################################
## Disallow PHP Easter Eggs (can be used in fingerprinting attacks to determine
## your PHP version).
RewriteCond %{QUERY_STRING} \=PHP[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12} [NC]
RewriteRule .* - [F]
@ostark
ostark / .htaccess
Last active August 29, 2015 14:17
Cache-Control headers for static assets
<ifModule mod_headers.c>
# Expires after 1 month
<filesMatch ".(gif|png|jpg|jpeg|ico|pdf|svg|js)$">
Header set Cache-Control "max-age=2592000"
</filesMatch>
# Expires after 1 day
<filesMatch ".(css)$">
Header set Cache-Control "max-age=86400"
</filesMatch>
<?php
/**
* Deploy sensitive files (laravel/passport example)
*
* OAUTH_PRIVATE_KEY (content of oauth-private.key) and OAUTH_PUB_KEY (content of oauth-public.key) must be stored in App Secrets
* https://help.fortrabbit.com/secrets
*
* Call this script post deployment (fortrabbit.yml)
* https://help.fortrabbit.com/deployment-file-v2#toc-a-minimal-example
*/
@ostark
ostark / fortrabbit.yml
Created April 7, 2017 10:01
composer global
pre: pre-deploy.php
sustained:
- vendor
- .composer-global
@ostark
ostark / bitbucket-pipelines.yml
Created May 23, 2017 14:21
use Bitbucket Pipelines with fortrabbit
image: php:7.1
pipelines:
branches:
master: # this branch gets deployed
- step:
script:
- apt-get update && apt-get install -y unzip git rsync
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install
# change APP and REGION
@ostark
ostark / array_unique_bench.php
Last active July 30, 2018 08:31
Craft micro optimization
<?php
/*
* Context:
* https://github.com/craftcms/cms/blob/3f055237e314362b079cbbf63a9be46b9cdcd7c7/src/helpers/Image.php#L65
*/
class ArrayHelper
{
@ostark
ostark / app.php
Created September 11, 2017 10:22
Craft 3 - Events - config/app.php
<?php
// VIEW EVENTS
$elements = [];
yii\base\Event::on(\craft\elements\db\ElementQuery::class, \craft\elements\db\ElementQuery::EVENT_AFTER_POPULATE_ELEMENT, function ($event) use (&$elements) {
// Don't collect MatrixBlock and User elements for now
if (in_array(get_class($event->element),['craft\elements\User', 'craft\elements\MatrixBlock'])) {
return;
}
@ostark
ostark / cloudflareWhitelistUpdate.php
Last active April 15, 2019 06:40
Updates the .htaccess with the recent ClouldFlare IPs
<?php
# Exec during deployment
# php cloudflareWhitelistUpdate.php public/.htaccess
$srcUrls = [
'https://www.cloudflare.com/ips-v4',
'https://www.cloudflare.com/ips-v6'
];
$htacessFile = $argv[1] ?? '.htaccess';
@ostark
ostark / tree.txt
Last active March 21, 2018 13:29
Craft cpresources
web/cpresources
├── 016a4edfe03d2d869433f50aa5c5f39f
│   ├── EntryDraftEditor.js
│   ├── EntryDraftEditor.min.js
│   ├── EntryDraftEditor.min.js.map
│   ├── EntryTypeSwitcher.js
│   ├── EntryTypeSwitcher.min.js
│   ├── EntryTypeSwitcher.min.js.map
│   ├── entry.css
│   ├── entry.css.map