Skip to content

Instantly share code, notes, and snippets.

View tertek's full-sized avatar

Ekin Tertemiz tertek

  • Swiss Tropical and Public Health Institute
  • Basel
View GitHub Profile
@tertek
tertek / export_fields_with_comments.sql
Last active January 7, 2021 11:21
SQL to export fields with all comments from REDCap
SELECT d.record, d.field_name, d.value, dqr.comment, dqr.ts as `Time Raised`, u.username as `User Assigned`, dqr.response
FROM `redcap_data` as d
LEFT JOIN `redcap_data_quality_status` as dqs ON d.record = dqs.record AND d.field_name = dqs.field_name
LEFT JOIN `redcap_data_quality_resolutions` as dqr ON dqr.status_id = dqs.status_id
LEFT JOIN `redcap_user_information` as u ON dqs.assigned_user_id = u.ui_id
WHERE
# exclude unneeded fields
d.field_name NOT LIKE "%_complete"
@tertek
tertek / big_data_import_workaround.sql
Created January 18, 2021 15:45
SQL to reset REDCap EM Big Data Import Module when stuck.
delete from redcap_external_module_settings
where `project_id`= 14 and `external_module_id` = 9
and `key` <> "enabled"
@tertek
tertek / REDCap_API_to_Stata_via_Pyhton_Example.do
Created February 8, 2021 11:07
Example of using REDCap API for exporting record data and importing into Stata via Python
python:
#!/usr/bin/env python
import requests
data = {
'token': '<PLEASE INSERT API TOKEN HERE>',
'content': 'record',
'format': 'csv',
'type': 'flat',
'csvDelimiter': '',
'records[0]': '1',
@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 () {
@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 / 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 / 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 / install-poppler-ubuntu.md
Last active June 29, 2022 10:51 — forked from Dayjo/install-poppler-ubuntu.md
How to install Poppler on Ubuntu

First install all these prerequisites for compiling:

sudo apt install g++ libboost-all-dev autoconf libfontconfig1-dev pkg-config libjpeg-dev libopenjp2-7-dev gnome-common libglib2.0-dev gtk-doc-tools libyelp-dev yelp-tools gobject-introspection libsecret-1-dev libnautilus-extension-dev

First download the encoding files (no need to compile these) to the current working directory

wget https://poppler.freedesktop.org/poppler-data-0.4.11.tar.gz
@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 / pcov-code-coverage-windows.md
Last active August 18, 2022 09:22
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