Skip to content

Instantly share code, notes, and snippets.

View digitensions's full-sized avatar
💻
Coding #DigiPres workflows

Joanna White digitensions

💻
Coding #DigiPres workflows
View GitHub Profile
@digitensions
digitensions / requests_examples.txt
Last active April 9, 2024 08:17
Push and Get using requests library in Python
#!/usr/bin/env python3
import os
import requests
import json
import tenacity
# GLOBAL API URL / HEADER
CUSTOM_API = os.environ['CUSTOM_API']
DATA_API = os.environ['DATA_API']
Recreate a folder:
folder = /path/N_123456_01of05
root = /path/N_123456_01of03/scan01/2048x1560
dpx_path = /path/N_123456_01of03
This command returns:
new_folder = os.path.join(folder2, os.path.relpath(root, dpx_path))
new_folder = /path/N_123456_01of05/scan01/2048x1560
os.path.relpath() returns the remainder of the first argument when the second is removed.
Git terminal shortcuts for Linux
[Part borrowed from cferdinandi - https://gist.github.com/cferdinandi/ef665330286fd5d7127d]
### Most used
cd into server repository you want to update
git init
git remote add upstream <upstream github url> # Add original as upstream
git merge upstream/main # Replaces local server version with GitHub repository
git log # Update of recent changes
# Switch between bash / zsh in Terminal:
chsh -s /bin/bash
Search in files for a string match, case ignored
grep -iRI "String to match"
nano <scriptname>.sh (or launch with nano, and ctrl + s to save later)
GNU nano, emulates a text editor and allows editing/writing of bash scripts.
Shortcuts:
ctrl + k - cut text
watch -n 4 'date ; echo ; free'
Monitoring memory on a Linux system
sudo apt install ubuntu-desktop-minimal
Install Ubuntu GNOME Desktop Minimal (ubuntu-desktop-minimal package)
Ubuntu GNOME Desktop Minimal is a flavor of Ubuntu GNOME that is smaller and
lighter than the full Ubuntu GNOME Desktop. It uses a slimmed-down software selection.
The purpose of this flavor is to provide a smaller, lighter system to those users
who have older hardware or who want a more minimal system.
On a fresh Ubuntu server install, it will take about ~800MB space.
@digitensions
digitensions / Command line shortcuts (I haven't remembered yet)
Last active May 1, 2020 09:31
Useful commands when working on Linux.
IN NO PARTICULAR ORDER, YET.
sudo reboot
Useful if your workstation hangs, as long as you can access a terminal.
gnome-session-quit
Log out of the workstation
gnome-screenshot -a
Drag/drop screenshot area (linux)
@digitensions
digitensions / DOS_to_BASH
Created November 15, 2019 09:52
Converting DOS Batch Files to Shell Scripts
Appendix N. Converting DOS Batch Files to Shell Scripts
Credit the Linux Documentation Project - https://www.tldp.org/LDP/abs/html/dosbatch.html
Quite a number of programmers learned scripting on a PC running DOS. Even the crippled DOS batch file language allowed writing some fairly powerful scripts and applications, though they often required extensive kludges and workarounds. Occasionally, the need still arises to convert an old DOS batch file to a UNIX shell script. This is generally not difficult, as DOS batch file operators are only a limited subset of the equivalent shell scripting ones.
Table N-1. Batch file keywords / variables / operators, and their shell equivalents
Batch File Operator / Shell Script Equivalent / Meaning
% $ command-line parameter prefix
/ - command option flag
@digitensions
digitensions / MACE_CLI_stuff.txt
Last active April 20, 2021 08:55
MACE CLI short cuts
MACE SPECIFIC CLI SHORTCUTS
FFMPEG CONVERSIONS
1. SD 4:3 MOV to H264 MOV (gop 1 intraframe):
ffmpeg -i input.mov -c:v libx264 -pix_fmt yuv420p -flags +ildct -map 0 -aspect 4:3 -g 1 -crf 14 -c:a copy -metadata "copyright=Copyright © 2019 Media Archive for Central England" -metadata "comment=To license this item please contact MACE on 01522 837750 or visit www.macearchive.org" output.mov
2. SD 16:9 MOV to H264 MOV (gop 1 intraframe):
# Coded by James Wingate, Katherine Frances Nagels and Joanna White
from ffprobe3 import FFProbe
import os
import re
import subprocess
import sys
# The keys are the shortform name for each resolution,
# corresponding to the expected .png watermark file.
@digitensions
digitensions / DPX_Weird_DAR4:3
Last active September 18, 2019 14:55
GE4 scan dimensions 4:3 / 2048x1513 / Pixel ratio horizontal & vertical 1...
C:\Users\MACE Digital Tech>mediainfo --Details=1 "T:\COMPLETED\DPX BEING PACKAGED\Scan01\25462_01_000000.dpx"
000000000 -------------------------
000000000 --- DPX, accepted ---
000000000 -------------------------
000000000 Generic section header (1664 bytes)
000000000 File information (768 bytes)
000000000 Magic number: XPDS
000000004 Offset to image data: 8192 (0x00002000)
000000008 Version number of header format: V2.0
000000010 Total image file size: 12402688 (0x00BD4000)