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 / README.md
Last active August 17, 2026 14:20
Interactive EC2 instance picker + SSH (test/stage/prod via aws-cli, grouped by Name tag, no dependencies)

ec2 — interactive EC2 instance picker with SSH

Lists running EC2 instances in one of your AWS environments (test, stage, prod), lets you pick one, and opens an SSH session to its private IP.

  • Instances are grouped by their Name tag: pick the role first, then the host
  • Arrow-key picker with type-to-filter; the last host per environment is preselected
  • No dependencies — Node builtins plus the aws, ssh and stty binaries

Written for a setup with one AWS account per environment, reached over a VPN or SSH tunnel.

@ostark
ostark / schema_auto_increment_columns.sql
Created December 4, 2024 14:17 — forked from bennadel/schema_auto_increment_columns.sql
Looking For Database Performance Bottlenecks And Optimizations Using The Sys Schema In MySQL 5.7
/**
* Find the amount of auto-increment "space" has been used. This may can help identify
* tables that are running out of available ID values.
*/
SELECT
t.table_name,
t.column_name,
-- The highest possible ID that can be created with this data-type.
t.max_value,
-- The last ID created in this table.
@ostark
ostark / TerminationSignals.php
Last active February 11, 2024 16:37
Better signal handling for long running Jobs in Craft
<?php
class TerminationSignals extends \yii\base\Module
{
public function init()
{
parent::init();
// Listen to SIGTERM
@ostark
ostark / NoFields.php
Created February 10, 2021 21:09
lightweight entry queries without custom fields
<?php
namespace modules;
class NoFields extends \craft\services\Fields
{
public function getAllFields($context = null): array
{
return [];
}
@ostark
ostark / sql.md
Last active December 10, 2020 11:20
CREATE TABLE products (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name JSON NOT NULL
);   

INSERT INTO products (name) VALUES('{"en": "Traffic lights", "de": "Verkehrsampel", "nl": "Stoplichten"}');
INSERT INTO products (name) VALUES('{"en": "Car", "de": "Auto", "nl": "Wagen"}');
INSERT INTO products (name) VALUES('{"en": "Bike", "de": "Fahrrad", "nl": "Fietsen"}');
INSERT INTO products (name) VALUES('{"en": "Airplane", "de": "Flugzeug", "nl": "Vliegtuig"}');
<?php
# Run this script once a day via cron
# to persist apache_access.log.1.gz log in ./storage/logs/
$src = '../logs/apache_access.log.1.gz';
$dest_dir = './storage/logs/';
$dest_prefix = 'apache_access.';
$dest_file = $dest_dir . $dest_prefix . date("Y-m-d", strtotime("yesterday")).'.log.gz';
$keep_max_files = 10;
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Laravel\Passport\Passport;
class PassportKeysCommand extends Command
{
const MAP = [
@ostark
ostark / EventCatcher.php
Created September 27, 2018 16:56
A wildcard event handler that logs all Yii/Craft events
class EventCatcher
{
/**
* @var array
*/
protected $classConstants = [];
public function __invoke(yii\base\Event $event)
{
@ostark
ostark / make-auth-json.php
Last active April 16, 2022 10:12
Creates auth.json from ENV vars
<?php
/**
* Example: Oauth with Github token
* php make-auth-json.php github-oauth.github.com GITHUB_TOKEN
*
* Example: Basic auth for private satis repo
* php make-auth-json.php http-basic.nova.laravel.com NOVA_USERNAME NOVA_PASSWORD
*/
// remove script name
@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