Skip to content

Instantly share code, notes, and snippets.

@greg-randall
greg-randall / index.php
Last active December 1, 2022 15:42 — forked from vsoch/index.php
Generate RSS feed for files in a directory folder. Put this file in a folder with files, modify the $allowed_ext variable to customize your extensions, and $feedName, and $feedDesc. Then navigate to the folder on the web to see the xml feed.
<?php
header("Content-type: text/xml");
$feed_name = "My Audio Feed";
$feed_description = "Feed for the my audio files in some server folder";
$base_url = strtok('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], '?'); //gets the current page's url. strips off the url's parameters
$allowed_extensions = array('mp4','mp3');
?>
<?php echo '<?xml version="1.0"?>'; //we have to use php to output the "<?" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
@greg-randall
greg-randall / html-clean.php
Last active March 1, 2019 18:03
Remove all html attributes except for the url of images and urls on links. It then cleans up html removing divs, spans, etc. Ideally used if you have a source of HTML from an existing site with a bunch of CSS classes you don't need.
<?php
if(!isset($_POST["input"])|$_POST["input"]==""){ //check to see if the url is set. if not set prompts for a url.
?>Clean:
<form action="index.php" method="post">
<textarea name="input" rows="40" cols="80"></textarea><br><br>
<input type="submit">
</form><?php
exit();
}else{
$input = htmlspecialchars_decode($_POST["input"]);
@greg-randall
greg-randall / Wordpress Export Notes
Last active January 24, 2022 19:24
Export all content from Wordpress but evaluate shortcodes before exporting.
I'm using this to get away from Enfold and Devi which marks everything up with hundreds of shortcodes. This will output ugly html, but at least it's html.
In wp-admin/includes/export.php change this line:
$content = wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
To:
$content = wxr_cdata( apply_filters( 'the_content_export', do_shortcode( $post->post_content ) ) );
@greg-randall
greg-randall / index.php
Created October 16, 2018 16:26
PHP Based Title Case, Insert acronyms that are specific to your field/industry
<?php
// Converts to proper case, deals with some edge cases, and capitalizes many medical acronyms.
// this assumes that the title is completely uppercase or completely lowercase that we get no hints
function proper_case($title)
{
// http://www.superheronation.com/2011/08/16/words-that-should-not-be-capitalized-in-titles/#comment-1945084
$lowercase_words = array('a ', 'aboard ', 'about ', 'above ', 'across ', 'after ', 'against ', 'along ', 'amid ', 'among ', 'an ', 'and ', 'anti ', 'around ', 'as ', 'at ', 'before ', 'behind ', 'below ', 'beneath ', 'beside ', 'besides ', 'between ', 'beyond ', 'but ', 'by ', 'concerning ', 'considering ', 'despite ', 'down ', 'during ', 'except ', 'excepting ', 'excluding ', 'following ', 'for ', 'from ', 'in ', 'inside ', 'into ', 'like ', 'minus ', 'near ', 'of ', 'off ', 'on ', 'onto ', 'opposite ', 'or ', 'outside ', 'over ', 'past ', 'per ', 'plus ', 'regarding ', 'round ', 'save ', 'since ', 'so ', 'than ', 'the ', 'through ', 'to ', 'toward ', 'towards ', 'unde
@greg-randall
greg-randall / thumbs_from_raw.sh
Last active October 19, 2021 20:39
Generate quick small thumbnails from a folder of raw files using DCRAW, ImageMagick, and cjpeg.
#!/bin/bash
if [ ! -d "../thumb" ]
then
mkdir ../thumb
fi
for i in *
do
if [[ $i == *.RWZ ]] || [[ $i == *.RW2 ]] || [[ $i == *.CR2 ]] || [[ $i == *.DNG ]] || [[ $i == *.ARW ]] || [[ $i == *.ERF ]] || [[ $i == *.NRW ]] || [[ $i == *.RAF ]] || [[ $i == *.NEF ]] || [[ $i == *.K25 ]] || [[ $i == *.DNG ]] || [[ $i == *.SRF ]] || [[ $i == *.EIP ]] || [[ $i == *.DCR ]] || [[ $i == *.RAW ]] || [[ $i == *.CRW ]] || [[ $i == *.3FR ]] || [[ $i == *.BAY ]] || [[ $i == *.MEF ]] || [[ $i == *.CS1 ]] || [[ $i == *.KDC ]] || [[ $i == *.ORF ]] || [[ $i == *.ARI ]] || [[ $i == *.SR2 ]] || [[ $i == *.MOS ]] || [[ $i == *.MFW ]] || [[ $i == *.CR3 ]] || [[ $i == *.FFF ]] || [[ $i == *.SRW ]] || [[ $i == *.J6I ]] || [[ $i == *.X3F ]] || [[ $i == *.KC2 ]] || [[ $i == *.RWL ]] || [[ $i == *.MRW ]] || [[ $i == *.PEF ]] || [[ $i == *.IIQ ]] || [[ $i == *.CXI ]] || [[ $i == *.MDC ]]
@greg-randall
greg-randall / gist:a75d5a0824f609430924c737f6c6244e
Last active May 15, 2021 18:24
Hardcode Subs with FFMPEG - SRT & WebVTT both seem to work.
ffmpeg -i input-without-subs.mp4 -c:v libx264 -vb 20M -c:a copy -vf subtitles=subs.srt output-with-subs.mp4
To change the font size use this one:
ffmpeg -i input.mp4 -c:a copy -c:v libx264 -vb 20M -vf "subtitles=try_1.en_us.srt:force_style='Fontsize=24'" output-with-subs.mp4
To do a two pass encode while hardcoding subs:
ffmpeg -y -i input.mp4 -vf subtitles=subs.srt -c:v libx264 -b:v 5000k -pass 1 -an -f mp4 /dev/null
ffmpeg -y -i input.mp4 -vf subtitles=subs.srt -c:v libx264 -b:v 5000k -pass 2 -c:a copy output.mp4
@greg-randall
greg-randall / gist:9c3c9ac8589cfac1f1cc959824bd3488
Created May 2, 2019 16:25
dialogue compressor procedure for audition
remove huge peaks if not in speaking areas
favorites: normalize to -0.1db
effects rack slot 2 - hard limiter:
-0.1 maximum amplitude
0 input boost
7 look ahead time
100 release time
@greg-randall
greg-randall / disk-space.php
Last active July 8, 2019 16:05
Prints out the free space and the total space on a web server.
<?php
$folder = ".";
$free = disk_free_space($folder);
$total = disk_total_space($folder);
echo '<strong>Free Space:</strong> ' . formatBytes($free) . ' (' . round( ($free / $total) * 100 , 1) . '%)<br>';
echo '<strong>Total Space:</strong> ' . formatBytes($total);
@greg-randall
greg-randall / size-of-all-directories.php
Last active March 3, 2020 16:43
Prints out a table with all the directories on a web server. Good for chasing down large files during a cleanup. Bytes column is for easy sorting in excel if needed. If you have a lot of files it will be slow.
<?php
$root = '.';
$min_size = 10485760;
/* in bytes.
1 mb = 1048576
10 mb = 10485760
100 mb = 104857600
1 gb = 1048576000
*/
@greg-randall
greg-randall / delete_all_files_and_folders.php
Last active July 8, 2019 18:59
This tries to delete everything in it's directory and lower -- files and folders. I made this to delete some files with weird names that I couldn't delete over FTP. It will probably delete itself. Be really really sure you want this before you do this.
<pre>
<?php
//ARE YOU SURE YOU WANT TO DELETE EVERYTHING???
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.'));
foreach ($rii as $file) {
echo $file->getPathname() . "<br>";