Skip to content

Instantly share code, notes, and snippets.


Andrey Savchenko Rarst

View GitHub Profile
Rarst / render-link.html
Last active Jun 10, 2022
Autoembed tweet links in Hugo with markdown render hook
View render-link.html
Rarst / ruleset.xml
Created Aug 27, 2020
My personal PHPCS ruleset for WP projects.
View ruleset.xml
<?xml version="1.0"?>
<ruleset name="WordPress-Modified">
<description>A custom coding standard.</description>
<rule ref="CognitiveComplexity.Complexity.MaximumComplexity">
<property name="maxCognitiveComplexity" value="5"/>
Rarst / style-guide.js
Last active Apr 28, 2020
Automagically add Tailwind–like CSS from Frontend Mentor style guide files.
View style-guide.js
.then((response) => {
return response.text();
.then((markdown) => {
function parseMarkdown(markdown) {
let css = '';
Rarst / git-gc.php
Created Mar 3, 2020
Find and garbage collect all Git repositories in path `php git-gc.php /path/to/walk`.
View git-gc.php
declare( strict_types=1 );
$path = $argv[1];
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $path ),
Rarst / hugo-remote-api.html
Last active Jan 18, 2022
Remote API example in Hugo static site build.
View hugo-remote-api.html
{{ with getJSON "" }}
<h3 class="text-left">Latest Talk</h3>
{{ $talks := (index .data 0) }}
{{ $latest :=index $talks 0 }}
<a href="{{ $latest.links.self }}">
<img src="{{ $latest.attributes.image.src }}" alt="{{ $latest.attributes.title }}"
class="img-responsive" style="max-height: 210px;border: 1px solid #eee" loading="lazy"/>
{{ end }}
Rarst / wp-email-log.php
Created Mar 31, 2019
A simple mu–plugin snippet for overriding and logging WP emails in development.
View wp-email-log.php
class R_Mailer {
function Send() {
error_log( wp_debug_backtrace_summary() );
add_action( 'phpmailer_init', function( &$mailer ) {
$mailer = new R_Mailer();
Rarst / github-release-download.php
Last active May 13, 2019
Quick and dirty WP endpoint to redirect to a download of attached file for a latest GitHub release.
View github-release-download.php
declare( strict_types=1 );
new class( 'Rarst', [ 'laps' ] ) {
private $owner, $repos;
private $endpoint = 'download';
public function __construct( string $owner, array $repos ) {
Rarst / getpatch.cmd
Last active Aug 26, 2022
Download a patch file from a GitHub branch. Arguments: repo name, branch name (e.g. `getpatch Rarst/wp-date trac-38771`).
View getpatch.cmd
curl > patches/%2.diff
Rarst /
Created Jan 9, 2018
What worked for me to install GitHub Pages (Jekyll) on Windows 7x64.

GitHub Pages (Jekyll) installation on Windows 7x64

Main install

  1. Install Ruby 2.4.3 via RubyInstaller (not 2.5, conflicts with things later)
  2. Let it install MSYS2 or do it yourself.
  3. gem install bundler
  4. gem install github-pages (this includes jekyll itself and is where things break most)
  5. jekyll -v (3.6.2 at the time of writing, a little behind latest 3.7)
  6. jekyll new myblog
  7. Edit myblog/Gemfile to comment out jekyll line and uncomment github-pages line.
Rarst / .scrutinizer.yml
Last active Aug 13, 2019
Scrutinizer config to install PHPUnit on the fly, without shipping in project dependencies.
View .scrutinizer.yml
- 'tests/*'
php: true
version: 7.2