Skip to content

Instantly share code, notes, and snippets.

@Xilonz
Xilonz / main.yml
Created October 30, 2019 22:48
Roots Trellis Github Actions Example
name: Deploy
on: [push]
jobs:
deploy_staging:
name: deploy to staging
runs-on: ubuntu-latest
container:
image: itinerisltd/tiller:latest
@kellymears
kellymears / application.php
Last active November 17, 2019 16:12
Trellis/Bedrock/Sentry versioned deployments
<?php
/**
* composer require sentry/sentry-sdk
*/
use Sentry;
Env::init();
// Bedrock application config...
<?php
/**
* Plugin Name: WP REST API Strict Mode
* Description: Triggers an error when unregistered parameters are used.
* Author: Ryan McCue
* Author URI: http://rmccue.io/
* Version: 0.1
*
* Requires https://core.trac.wordpress.org/ticket/35507
*/
@Log1x
Log1x / application.php
Last active April 3, 2020 20:38 — forked from swalkinshaw/application.php
Trellis + Sentry
<?php
/**
* composer require sentry/sentry-sdk
*/
Env::init();
// ...
if (env('SENTRY_DSN') && env('WP_ENV') !== 'development') {
@matiaskorhonen
matiaskorhonen / check-certificate.rb
Last active April 19, 2021 21:53
Check an SSL/TLS certificate in Ruby (with SNI support)
# Modified from:
# http://findingscience.com/ruby/ssl/2013/01/13/reading-an-ssl-cert-in-ruby.html
require "socket"
require "openssl"
host = "www.piranhas.co"
tcp_client = TCPSocket.new("www.piranhas.co", 443)
ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_client)
@Killavus
Killavus / ugly_code_refactoring.coffee
Last active March 14, 2022 17:52
Example of possible refactoring of badly written code - loading photos and making it grayed after click
Photos = {}
class Photos.App
constructor: ->
@gui = new Photos.Gui($("#photos-list"))
@backend = new Photos.Backend()
start: =>
@backend.fetchPhotos()
.done(
@strarsis
strarsis / guide.md
Last active February 19, 2023 00:29
Object caching with Bedrock (and Trellis) using Redis

Object caching with Bedrock (and Trellis) using Redis

What is object caching

While nginx microcaching already solves page caching (as of static, rarely changing WordPress pages), the performance for dynamically generated pages (like WooCommerce shop pages and admin backend in general) can benefit greatly from additionally using an object cache. Object caching allows an application (in this case WordPress with its plugins, theme, etc.) to store prepared objects (mostly database queries) in a database and quickly retrieve them, therefore improving the performance of dynamic page generation. Object caching is (usually) transparent, which means that it shouldn't be noticeable by users and developers (except for the performance improvements of course).

Implementations

@motemen
motemen / push-gh-pages.sh
Last active April 29, 2023 14:55
Shell script to setup/push GitHub pages
#!/bin/sh
# usage: push-gh-pages DIRECTORY # DIRECTORY is where GitHub pages contents are in (eg. build)
# LICENSE: Public Domain
set -e
remote=$(git config remote.origin.url)
described_rev=$(git rev-parse HEAD | git name-rev --stdin)
@swalkinshaw
swalkinshaw / application.php
Created November 17, 2019 17:29
Trellis + Sentry
<?php
/**
* composer require sentry/sentry-sdk
*/
use Sentry;
Env::init();
// Bedrock application config...
if (env('SENTRY_DSN')) {
Sentry\init([
'dsn' => env('SENTRY_DSN'),
@alexanderadam
alexanderadam / Ansible Disk Check
Created September 15, 2018 12:40 — forked from mahemoff/Ansible Disk Check
Show disk space and warn about disk full in Ansible
* Shows a message while asserting like:
ok: [host] => {
"msg": "disk usage 4.2B of total 20.0GB (21.0%) (should exceed limit 90.0%)"
}
* Note this only looks at first mount point on current node
* Fails if disk is near-full
* Last step pushes to a push-based monitoring service, which will alert us if it doesn't get there after some time
* Need to setup a variable `disk_limit`, which is the max acceptable usage ratio, e.g. set it to 0.8 if you want to keep disks within 80% of max size