Skip to content

Instantly share code, notes, and snippets.

@tertek
tertek / initial_setup.sh
Created January 22, 2024 07:50
Initial Setup Script for a VPS running Linux Ubuntu
#!/bin/bash
set -euo pipefail
########################
### SCRIPT VARIABLES ###
########################
# Name of the user to create and grant sudo privileges
USERNAME=sammy
@tertek
tertek / remote-odk.py
Last active December 5, 2023 09:24
Test python remote code execution for zapier
def hello():
return "Hello World from Github"
test = hello()
output = [{'test-2': test}]
@tertek
tertek / redcap-testing.php
Last active August 19, 2022 10:39
REDCap Testing Helpers
<?php
function addRepeatingForm($projectId=null, $eventId=null, $form=null, $customLabel=null) {
// Prepare parameters
if($projectId === null) {
$projectId = PROJECT_ID;
}
if($eventId === null){
@tertek
tertek / pcov-code-coverage-windows.md
Last active January 7, 2025 05:33
PHPUnit Code-Coverage with PCOV on Windows (Local Development Environment)

PHPUnit Code-Coverage with PCOV on Windows

Download and Install PCOV

  1. Download latest release (currently 1.0.11) for Windows for your version of PHP and the correct format (ts or nts) from PECL
  2. Unzip downloaded package and copy the files php_pcov.dll and php_pcov.pdb to your PHP extensions directory, e.g. C:\bin\php\php-7.4.27-Win32-vc15-x64\ext\
  3. Modify your php.ini so that PCOV is loaded. Therefore add extension=pcov:
..
extension=fileinfo
extension=gd2
@tertek
tertek / local-composer-package.md
Created August 16, 2022 06:46
Local Composer Package Development

Example package with structure:

project
│   composer.json
│   ...
│
└───packagename
│   │   composer.json
│   │
│ └───src
@tertek
tertek / install-old-gcc.md
Last active June 21, 2022 13:36
How to install older gcc versions on Linux

Manual Install

Basic instructions: https://gcc.gnu.org/install/index.html

  1. Download source from mirror && unpack
  2. Download prerequirements with script ./contrib/download_prerequisites
  3. sudo apt-get install gcc-multilib
  4. Run configuration script
  5. Run make
  6. Run install
@tertek
tertek / docker-commands.sh
Last active June 8, 2022 15:07
Useful Docker Commands
# Clear Build Cache
# https://docs.docker.com/engine/reference/commandline/builder_prune/
$ docker builder prune
# Remove Image
# https://docs.docker.com/engine/reference/commandline/image_rm/
$ docker image rm IMAGE
# Run docker build with output to console
# https://stackoverflow.com/a/69524819/3127170
@tertek
tertek / .htaccess
Last active June 7, 2022 06:52
Rewrite Rules needed for pretty URLs for the REDCap Module Repo API
RewriteEngine On
# Rewrite Rules needed for pretty URLS for the Modules API
# Add trailing slash to all requests within /api directory
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
# Route URL Query parameters to pretty URls with "endpoints" - DO NOT CHANGE THE ORDER - can break things
RewriteRule ^v1/$ ?NOAUTH&pid=472&type=module&prefix=em_submission_module&page=module-repo-api
@tertek
tertek / odk-central-on-windows.md
Last active April 21, 2025 15:20
Installing ODK Central on Windows 10

Installing ODK Central on Windows 10

This guide helps you to setup ODK Central on Windows 10 whereby OS specific problems are being fixed.

Prerequisites

  • Node.js
  • Docker & Docker Compose (Docker Desktop recommended)
  • Git
@tertek
tertek / pdfToThumbnailImage.js
Created April 20, 2021 09:01
PDF to Thumbnail Image with pdf.js
function makeThumb(page) {
// draw page to fit into 96x96 canvas
var vp = page.getViewport({ scale: 1, });
var canvas = document.createElement("canvas");
var scalesize = 1;
canvas.width = vp.width * scalesize;
canvas.height = vp.height * scalesize;
var scale = Math.min(canvas.width / vp.width, canvas.height / vp.height);
console.log(vp.width, vp.height, scale);
return page.render({ canvasContext: canvas.getContext("2d"), viewport: page.getViewport({ scale: scale }) }).promise.then(function () {