Skip to content

Instantly share code, notes, and snippets.

View tillkruss's full-sized avatar
🏠
Working from home

Till Krüss tillkruss

🏠
Working from home
View GitHub Profile
@tillkruss
tillkruss / versions.md
Last active March 22, 2024 07:12
PHP API versions

PHP API versions

Version API
7.3 20180731
7.4 20190902
8.0 20200930
8.1 20210902
8.2 20220829
8.3 20230831
@tillkruss
tillkruss / leaddyno.html
Last active July 13, 2021 17:29
Async Lead Dyno script
<script>
(function(key) {
var script = document.createElement('script');
script.src = 'https://static.leaddyno.com/js';
script.async = true;
script.onload = function () {
LeadDyno.key = key;
LeadDyno.recordVisit();
LeadDyno.autoWatch();
};
@tillkruss
tillkruss / ocp.sh
Last active November 18, 2021 18:15
cd ./wordpress
wget https://objectcache.pro/plugin/redis-cache-pro.zip?token=0000000000 | unzip
cp redis-cache-pro/stubs/mu-plugin.php wp-content/mu-plugins/redis-cache-pro.php
mv redis-cache-pro wp-content/mu-plugins
rm redis-cache-pro.zip
read -r -d '' WP_REDIS_CONFIG <<- EOM
@tillkruss
tillkruss / cluster.php
Last active April 9, 2021 01:30
PhpRedis Cluster Test
<?php
var_dump('PhpRedis: '. phpversion('redis'));
$redis = new RedisCluster(
null,
[
'tls://127.0.0.1:7001',
'tls://127.0.0.1:7002',
],
@tillkruss
tillkruss / worker.js
Created July 17, 2018 16:18
A Cloudflare worker that allow cookie/path based caching.
/**
* Time-to-live in seconds for cached requests.
*/
const cacheTtl = 300;
/**
* List of request paths to cache.
*/
const cachedPaths = [
@tillkruss
tillkruss / AppServiceProvider.php
Last active April 19, 2024 09:23
ElasticSearch engine for Laravel Scout
<?php
resolve(EngineManager::class)->extend('elasticsearch', function ($app) {
return new ElasticsearchEngine(
ElasticBuilder::create()->setHosts(config('scout.elasticsearch.hosts'))->build()
);
});
@tillkruss
tillkruss / README.md
Last active June 22, 2020 10:11
AWS Lambda function that optimizes images uploaded to a S3 bucket using Kraken.io's API.

Lambda S3 Kraken

Trigger

  • Event type: ObjectCreated
  • Suffix: jpg

Environment variables

  • AWS_KEY
  • AWS_SECRET
  • KRAKEN_SECRET
@tillkruss
tillkruss / stream-s3-as-zip.php
Last active April 6, 2020 08:28
Stream files from S3 as ZIP file.
<?php
use Aws\S3\S3Client;
use ZipStream\ZipStream; // https://github.com/maennchen/ZipStream-PHP
use GuzzleHttp\Client as HttpClient;
protected function streamAsZip($files)
{
$s3 = S3Client::factory('...');
$zip = new ZipStream("foobar.zip");
@tillkruss
tillkruss / AuthServiceProvider.php
Last active November 8, 2021 12:38
Case-insensitive PostgreSQL eloquent user provider for Laravel 5.
<?php
namespace App\Providers;
use Auth;
use App\Support\EloquentUserProvider;
class AuthServiceProvider extends ServiceProvider
{
public function boot(GateContract $gate)

Keybase proof

I hereby claim:

  • I am tillkruss on github.
  • I am tillkruss (https://keybase.io/tillkruss) on keybase.
  • I have a public key whose fingerprint is 6490 DEB6 8D18 F0A3 49BD CB9C 8874 10C6 42BC 23BB

To claim this, I am signing this object: