Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Setting my status

Sander van Dragt svandragt

💭
Setting my status
View GitHub Profile
@svandragt
svandragt / demo.php
Last active Jan 27, 2021
phpquery maintainable demo
View demo.php
<?php
namespace SvanDragt\Test;
require_once __DIR__ . '/vendor/autoload.php';
use phpQuery;
function do_parse() {
// INITIALIZE IT
// phpQuery::newDocumentHTML($markup);
@svandragt
svandragt / index.php
Created Jan 26, 2021
Altis Local Server index
View index.php
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which tells WordPress to load the theme.
*
* @package WordPress
*
* DO NOT EDIT THIS FILE.
*
* phpcs:disable PSR1.Files.SideEffects
@svandragt
svandragt / upgrade.sh
Last active Oct 29, 2020
Basic upgrade script
View upgrade.sh
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
do_upgrade() {
VERSION_FILE=".bin/upgrade.version"
if [ ! -f $VERSION_FILE ]; then
touch $VERSION_FILE
fi
@svandragt
svandragt / countdown.sh
Last active May 28, 2020
countdown cli
View countdown.sh
#!/usr/bin/env bash
# v3 - 2020-05-28
if [ $# -eq 0 ]; then
echo "countdown.sh <seconds> \"<message>\""
exit 1
fi
secs=$1
msg=${2:-$1 seconds passed.}
while [ $secs -gt 0 ]; do
echo -ne "$secs\033[0K\r"
@svandragt
svandragt / stream_zip.php
Last active Mar 10, 2020
Zip files in a streamable way, with a 2MB memory footprint.
View stream_zip.php
<?php
// composer init; composer require maennchen/zipstream-php
error_reporting(-1);
require_once __DIR__ .'/vendor/autoload.php';
function stream_zip( array $files, string $out_file ) {
$out = fopen( 'file://' . $out_file, 'w' );
$options = new ZipStream\Option\Archive();
$options->setOutputStream( $out );
@svandragt
svandragt / composer.json
Last active Dec 12, 2019
Replace plugin with non-packagist composer version, in custom location.
View composer.json
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/wp-shortcake/shortcake"
},
],
"require": {
"oomphinc/composer-installers-extender": "^1.1",
"fusioneng/shortcake": "dev-master#0.7.4"
@svandragt
svandragt / .bashrc
Last active Oct 29, 2019
Git Helper
View .bashrc
alias git-create="git-util.py $1 $2"
@svandragt
svandragt / csv2bm.py
Last active Oct 23, 2019
Convert (Instapaper) CSV to Netscape Bookmark File
View csv2bm.py
#!/usr/bin/env python
"""
Convert CSV to Netscape Bookmark File
Works for files exported by Instapaper.
author: Sander van Dragt <sander@vandragt.com>
version: 2019-10-23.01
"""
import csv
from sys import argv
@svandragt
svandragt / how-i-work-template.md
Last active Jul 14, 2021 — forked from jazzsequence/how-i-work-template.md
How I Like to Work posts (2021-06)
View how-i-work-template.md

How I work

This is my own interpretation of how I like to work, feedback welcome! If this doesn't match your experience of how I like to work, let me know! ;)

When I work

I'm almost always in the UK. I operate from the BST/GMT timezone (https://time.is/Edinburgh). I follow a 9am-5pm working hours format, this is best for my family. Occasionally I might take a nap and work late to compensate.

I tend to work 7 hours a day with ideally the last hour of the day for email and next-day planning.

Where I work

I work from home. My dog might walk in on our meeting!

@svandragt
svandragt / upgrade.sh
Last active Aug 26, 2019
Known CMS upgrade automation (https://withknown.com/)
View upgrade.sh
#!/usr/bin/env bash
rm -rf old
cp -R html old
pushd html
git stash
git pull
composer update
cd ..
ln -sf `pwd`/config.ini `pwd`/html/config.ini
ln -sf `pwd`/Uploads `pwd`/html/Uploads