Skip to content

Instantly share code, notes, and snippets.

Matthew Setter settermjd

View GitHub Profile
@settermjd
settermjd / print-ocapps-uniq-dir-names-human-readable.sh
Last active Jan 30, 2019
Bash one-liner to print a list of unique names in ownCloud apps
View print-ocapps-uniq-dir-names-human-readable.sh
# Create a temporary file to store the results of the script
tmpfile=$(mktemp /tmp/dirnames.XXX);
# Print the directories found in each app directory
for i in $( ls . )
do
ls -A $i >> $tmpfile
done
# Sort and print a unique list of the discovered directories
@settermjd
settermjd / Dockerfile
Last active Jan 10, 2019
Custom owncloud-ubuntu Dockerfile
View Dockerfile
FROM owncloud/ubuntu:18.04
VOLUME ["/mnt/data"]
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["/usr/local/bin/entrypoint"]
CMD ["/usr/local/bin/owncloud"]
@settermjd
settermjd / complexity-example.c
Created Jul 12, 2018
A small C program for the sakes of demonstrating cyclomatic complexity
View complexity-example.c
#include <stdio.h>
#include <time.h>
#include <string.h>
int main()
{
time_t t = time(NULL);
struct tm tm = *localtime(&t);
const char * months[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
View zend-db-sql-join-example.php
<?php
// other setup code...
$select
->where([
'id = ?' => $userId
])
->join(
['r' => 'tblroles'],
View git-backport.sh
#!/bin/bash
# Inspired by http://www.devthought.com/code/create-a-github-pull-request-from-the-terminal/
targetbranch=master
if test "$1"; then
targetbranch=$1
fi
repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`
@settermjd
settermjd / backport-pr.sh
Created Feb 13, 2018
Script to backport a PR to branch (used mainly for working with the ownCloud documentation)
View backport-pr.sh
#!/bin/bash
set -e
# Script to backport a PR to branch
# ./backport-pr.sh backportTo backportFrom prId
# This script requires two other tools:
# - github-api-tools
# - git-backport
# add your GitHub credentials
View keybase.md

Keybase proof

I hereby claim:

  • I am settermjd on github.
  • I am settermjd (https://keybase.io/settermjd) on keybase.
  • I have a public key ASAL6A3SHjLSE8X0cePFas3u7nE7xwlxHc4mxwkFNNj2ugo

To claim this, I am signing this object:

@settermjd
settermjd / git-delete-branches.sh
Created Jan 17, 2018
Delete branches matching the provided pattern
View git-delete-branches.sh
#!/bin/bash
if (( $# != 1 ))
then
echo "Not enough arguments supplied."
echo " usage: git-delete-branches <branch pattern to search on>"
exit
fi
BRANCH_PATTERN=$1
@settermjd
settermjd / custom.zsh
Created Dec 12, 2017
Custom ZSH functions for working with the ownCloud documentation
View custom.zsh
# Simple function to search the ownCloud docs for a text string
function search_docs() {
if (( $# == 0 )); then
echo "Not enough arguments supplied."
echo " usage: search_docs <string to find>"
return -1;
fi
echo "Searching ownCloud documentation for: '$1'"
grep -rin "$1" $DOCS_HOME/*_manual/ --include="*rst"
@settermjd
settermjd / filter-images-by-width.sh
Created Nov 30, 2017
Find images whose width is greater than X
View filter-images-by-width.sh
#!/bin/bash
set -e
# Set the width from the first argument (could do this with getopts).
width=$1
# Filter the images using a combination of file and awk.
file images/* | awk -v width="$width" '{ if ($5 > width) print $1 }' | tr -d ':'
You can’t perform that action at this time.