Skip to content

Instantly share code, notes, and snippets.

View JanPetterMG's full-sized avatar

Jan-Petter Gundersen JanPetterMG

View GitHub Profile
@Tras2
Tras2 / cloudflare-ddns-update.sh
Last active May 31, 2024 11:55
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#!/bin/bash
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# Used to provide DDNS service for my home
# Needs the DNS record pre-creating on Cloudflare
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
@daveajones
daveajones / jsonfeed2rss.php
Last active August 15, 2023 21:06
Convert JSONFeed to RSS
<?php
//Convert JSONfeed to RSS in a single function as a drop-in to make adding JSONfeed
//support to an aggregator easier
function convert_jsonfeed_to_rss($content = NULL, $max = NULL)
{
//Test if the content is actual JSON
json_decode($content);
if( json_last_error() !== JSON_ERROR_NONE) return FALSE;
@wpscholar
wpscholar / greatest-common-divisor.php
Last active April 9, 2021 15:43
Euclidean algorithm - Find the greatest common divisor of two integers
<?php
/**
* Returns the greatest common divisor of two integers using the Euclidean algorithm.
*
* @param $a
* @param $b
*
* @return int
*/
function get_greatest_common_divisor( $a, $b ) {
@jasny
jasny / mysql_splitdump.sh
Last active February 15, 2024 16:13
Split MySQL dump SQL file into one file per table or extract a single table
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo "USAGE $0 DUMP_FILE [TABLE]"
exit
<?php
/**
* Set the base URL of the request; i.e., the segment leading to the script name
*
* E.g.:
* - /admin
* - /myapp
* - /subdir/index.php
*
* Do not use the full URI when providing the base. The following are