Skip to content

Instantly share code, notes, and snippets.

@jonom
jonom / DownloadCloudwaysLocalBackups.sh
Created October 4, 2019 03:30
CloudWays - bash script to download local backups for all applications on a server
#!/bin/bash
# CloudWays - Download local backups for all applications
# =======================================================
# * Local backups must be enabled and available. See https://support.cloudways.com/how-to-download-a-full-backup/
# * Add your machine's SSH key to your server so this script needs no input.
# * Backups will be saved inside a new folder with today's date within your nominated backup directory. (This might not be the date the backup was taken.)
# * Only tested on Digital Ocean VPS so far.
# Configuration

gif-from-tweet

There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.

Dependencies

  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
@wilr
wilr / Page.php
Created February 6, 2018 20:35
Snippet for namespaced SilverStripe Pagetypes to find their controller in a different namespace.
<?php
namespace App\Project\Model;
use SilverStripe\Core\ClassInfo;
use SilverStripe\CMS\Model\SiteTree;
use App\Project\Control\PageController;
class Page extends SiteTree
{
@dhensby
dhensby / git-sync.sh
Last active February 2, 2016 17:23
A shell utility to sync your (local) branches with an arbitrary remote
#!/usr/bin/env bash
REMOTE_TO_SYNC='upstream' # default remote if none passed
QUIET=false # run in quiet mode
DO_PUSH=false # push to the branches upstream as part of the sync
ONLY_LOCAL=false # Only sync local branches (don't pull down from remote)
SKIP_FETCH=false # Skip the fetch step - really only useful if you know your up to date
Q_FLAG='' # the -q flag for CLI commands - changes to `-q` when running in quiet mode
DEBUG=false
@davidhund
davidhund / pragmatic-touch-icons.md
Last active September 4, 2020 15:42
Pragmatic Touch Icons

NOTE I'm trying to find the most optimal fav/touch icon setup for my use-cases. Nothing new here. Read Mathias Bynens' articles on re-shortcut-icon and touch icons, a FAQ or a Cheat Sheet for all the details.

I'd like to hear how you approach this: @valuedstandards or comment on this gist.

The issue

You have to include a boatload of link elements pointing to many different images to provide (mobile) devices with a 'favicon' or 'touch icon':

![Touch Icon Links](https://o.twimg.com/2/proxy.jpg?t=HBj6AWh0dHBzOi8vcGhvdG9zLTYuZHJvcGJveC5jb20vdC8yL0FBRGFGY1VRN1dfSExnT3cwR1VhUmtaUWRFcWhxSDVGRjNMdXFfbHRJWG1GNFEvMTIvMjI3OTE2L3BuZy8xMDI0eDc2OC8yL18vMC80L1NjcmVlbnNob3QlMjAyMDE1LTA0LTE0JTIwMTYuNTYuMjYucG5nL0NNejBEU0FCSUFJZ0F5Z0JLQUkvNGR1eDZnMzZmYnlzYWI3

@nikic
nikic / bench.php
Last active November 2, 2023 22:49
Benchmark of call_user_func_array vs switch optimization vs argument unpacking syntax
<?php error_reporting(E_ALL);
function test() {}
$nIter = 1000000;
$argNums = [0, 1, 2, 3, 4, 5, 100];
$func = 'test';
foreach ($argNums as $argNum) {