Skip to content

Instantly share code, notes, and snippets.

View JohnRDOrazio's full-sized avatar
✝️
Focusing

John R. D'Orazio JohnRDOrazio

✝️
Focusing
View GitHub Profile
@JohnRDOrazio
JohnRDOrazio / gist:c57a8739bf26e1801385c35321d9db81
Created June 10, 2024 20:11
remove local git branches that are no longer on remote - one liner bash
git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done
@JohnRDOrazio
JohnRDOrazio / Ctrl-Shift-C-Should-Copy.js
Last active April 28, 2023 10:01
when using the web based SSH terminal provided by the Plesk interface, there is no way to copy the text from the terminal since it is a canvas element. This script will allow to use Ctrl-Shift-C to copy instead of opening developer tools
/* Intercept and check keydown events for Ctrl+Shift+C */
document.body.addEventListener('keydown', function(evt){
if (evt.ctrlKey && evt.shiftKey && evt.key == "C"){
// Copy the selection to the clipboard
document.execCommand('copy');
// Throw away this event and don't do the default stuff
evt.stopPropagation();
evt.preventDefault();
}
@JohnRDOrazio
JohnRDOrazio / bgetHelper.php
Created April 23, 2023 20:34
a simple PHP helper script used on the Semina Verbi wiki project, to retrieve Bible quotes from the BibleGet API and store them locally
<?php
header('Content-Type: application/json');
$DATA = new stdClass();
$DATA->http_referer = $_SERVER['HTTP_REFERER'];
/**
* Only allow access to this script via ajax requests from this same server
* if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest' ){
* $DATA->message = "Not an ajax request";
@JohnRDOrazio
JohnRDOrazio / diskspace.sh
Last active November 1, 2023 10:08
List files/folders by size in descending order, limit 20
sudo du -hsx --exclude=/{proc,sys,dev,run} /*| sort -hr | head -n20
sudo nano /usr/share/i18n/locales/la_VA
# PASTE contents from https://sourceware.org/bugzilla/attachment.cgi?id=13866
sudo nano /usr/share/i18n/SUPPORTED
# add 'la_VA.UTF-8 UTF-8' to the list
sudo locale-gen la_VA.UTF-8
LC_TIME=la_VA.UTF-8 date
# should output something like:
# Fer VI 18 Feb 2022, 12:35:36 CET
LC_TIME=la_VA.UTF-8 date +"%A %-d %B %Y, %T %Z"
# should output something like:
<!DOCTYPE html>
<html lang="it">
<head>
<title>Medjugorje</title>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" name="viewport">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta name="pdfkit-page-size" content="A4"/>
<meta name="pdfkit-orientation" content="Portrait"/>
<meta name="pdfkit-dpi" content="300"/>
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
html {
font-family:"Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
-ms-text-size-adjust:100%;
-webkit-text-size-adjust:100%;
position:relative;
}
body {
margin:0;
padding: 36px;
from flask import make_response, Flask
import pdfkit
import os
path_wkhtmltopdf = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
pdfoptions = {
"print-media-type": None,
"page-size": "A4",
"dpi": "300",
let liturgyToday = {};
$.getJSON('https://www.johnromanodorazio.com/LiturgicalCalendar/LitCalEngine.php?diocesanpreset=DIOCESIDIROMA',function(data){
for(const [key,entry] of Object.entries(data.LitCal)){
let entryDate = new Date(entry.date * 1000);
if(entryDate.getUTCMonth() == new Date().getMonth() && entryDate.getUTCDate() == new Date().getDate()){
liturgyToday[key] = entry;
}
}
});
@JohnRDOrazio
JohnRDOrazio / plugin.js
Last active October 17, 2020 19:35
WordPress AJAX example for Liturgical Calendar API
jQuery(document).ready(function($) {
var data = {
'action': 'call_litcal_api',
'nationalpreset': 'USA'
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.get(ajaxurl, data, function(response) {
alert('Got this from the LitCal API: ' + response);