Skip to content

Instantly share code, notes, and snippets.

View svandragt's full-sized avatar
🤞

Sander van Dragt svandragt

🤞
View GitHub Profile
@svandragt
svandragt / VagrantFile
Last active June 4, 2018 18:13
dynamic mount points in vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
current_dir = File.dirname(File.expand_path(__FILE__))
configs = YAML.load_file("#{current_dir}/config.yaml")
Vagrant.configure("2") do |config|
# ...
@svandragt
svandragt / unziplong.sh
Created June 12, 2018 10:42
Unzip long filenames
#!/bin/bash
if (( $# == 0 )); then
echo "$0 my.zip"
exit 1
fi
fbase=$(basename "$1")
fdir="${fbase%.*}"
mkdir "$fdir"
@svandragt
svandragt / other.sh
Created September 24, 2018 13:20
Bash variable scope
export SURNAME='Bob'
@svandragt
svandragt / notes-to-evernote-migration.scpt
Last active April 7, 2019 13:06
Migrate Apple Notes to EverNote
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
(*
Create a folder in Apple Notes called Exported
Create a folder in Evernote called Imported
Then for each folder set the variable to the name of the folder
Known issues: doesn't copy images, scanned documents and embedded links (it's html).
Workaround: select note contents, copy and paste into Evernote. Scanned documents can be exported to PDF and dragged into EverNote.
@svandragt
svandragt / iup.sh
Last active May 6, 2019 14:12
Upload latest screenshot in ~/Pictures and notify URL and send to clipboard
#!/bin/bash
# v1 - 2019-05-06
# Upload latest screenshot in ~/Pictures and notify URL and send to clipboard
# requires a domain to upload; xclip to send to clipboard; and gnome to notify.
SITE='https://my.domain'
FILE=$(ls -t ~/Pictures/Screenshot*.png | head -1)
if [ ! -z "$FILE" ]; then
HASH=$(md5sum "$FILE"| head -n1 | awk '{print $1;}')
mv "$FILE" "/tmp/${HASH}.png"
@svandragt
svandragt / variety-of-files.php
Last active July 10, 2019 14:12
WordPress Theme Feature Setup
<?php
// mu-plugins/theme-features.php
require_once( FEATURES_DIR . '/myfeature.php' );
// mu-plugins/theme-features/myfeature.php
function features_myfeature_init() {
if ( current_theme_supports( 'myfeature' ) ) {
add_action( 'some_hook', 'features_myfeature' );
}
@svandragt
svandragt / upgrade.sh
Last active August 26, 2019 10:53
Known CMS upgrade automation (https://withknown.com/)
#!/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
@svandragt
svandragt / csv2bm.py
Last active May 13, 2024 07:20
Convert (Instapaper) CSV to Netscape Bookmark File
#!/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 / .bashrc
Last active October 29, 2019 09:58
Git Helper
alias git-create="git-util.py $1 $2"
@svandragt
svandragt / composer.json
Last active December 12, 2019 12:00
Replace plugin with non-packagist composer version, in custom location.
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/wp-shortcake/shortcake"
},
],
"require": {
"oomphinc/composer-installers-extender": "^1.1",
"fusioneng/shortcake": "dev-master#0.7.4"