Skip to content

Instantly share code, notes, and snippets.

Avatar

David Condrey dcondrey

View GitHub Profile
@dcondrey
dcondrey / _xcode.sh
Last active Sep 28, 2021
(macOS Big Sur) Install Xcode from terminal, setup local development with Apache and PHP 8, and other configurations
View _xcode.sh
# Install Command-line tools as dependency for Homebrew
xcode-select --install # Sets the development directory path to /Library/Developer/CommandLineTools
# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Mas (command-line interface for Mac App Store)
brew install mas
# Search for Xcode showing only the first 5 results
mas search xcode | head -5
@dcondrey
dcondrey / savetoDoc.js
Created Aug 5, 2017
Export an HTML element to Microsoft Word with CSS styles to set page orientation and paper size.
View savetoDoc.js
/* HTML to Microsoft Word Export
* This code demonstrates how to export an html element to Microsoft Word
* with CSS styles to set page orientation and paper size.
* Tested with Word 2010, 2013 and FireFox, Chrome, Opera, IE10-11
* Fails in legacy browsers (IE<10) that lack window.Blob object
*/
function saveDoc() {
if (!window.Blob) {
alert('Your legacy browser does not support this action.');
@dcondrey
dcondrey / ffmpegchapters-explicit.sh
Created Apr 20, 2016
Use ffmpeg to split file by chapters. Python version and bash version
View ffmpegchapters-explicit.sh
#!/bin/bash
# Author: http://crunchbang.org/forums/viewtopic.php?id=38748#p414992
# m4bronto
# Chapter #0:0: start 0.000000, end 1290.013333
# first _ _ start _ end
while [ $# -gt 0 ]; do
ffmpeg -i "$1" 2> tmp.txt
View contrast-color.js
/**
* Calculate the contrast of a color to determine the appropriate opposing text color.
* @author D. Condrey
* @param {string|object} - element background-color or element
* @return {string}
* white - if background is a dark shade color
* black - if background is a light shade color
*/
define(function() {
View resetForms.css
select, input, button, textarea {
font-size: 100%;
font-family: Arial, sans-serif;
font-weight: normal;
vertical-align: baseline;
margins: 2px 2px 10px 0;
padding: 4px 3px;
}
input, button, textarea {
@dcondrey
dcondrey / mcedemo_plugin.js
Created Dec 7, 2014
Add Page-Break, Highlight/Background-Color, extra buttons into the third row (row empty by default), extra buttons into the fourth row (row empty by default), modify dropdown menus, other misc mods
View mcedemo_plugin.js
(function() {
tinymce.create('tinymce.plugins.WRAP', {
init : function(ed, url) {
/* wrapping button take 1 */
ed.addButton('demobutton0', {
title : 'Wrap Selection in green!',
cmd : 'mceWRAP',
image : url + '/coffee.png'
});
@dcondrey
dcondrey / front-end-title-edit.js
Created Dec 7, 2014
Basic WP plugin, front-end editing with ajax
View front-end-title-edit.js
jQuery(document).ready( function($) {
$('.entry-title a').after( ' <button class="edit-title">EDIT</button>');
$('.entry-title').on( 'click', '.edit-title', function(ev) {
ev.preventDefault();
var postId = $(this).closest('article.post').attr('id').replace('post-','');
$a = $(this).prev('a'),
title = $a.text(),
newTitle = prompt( 'New Title', title );
@dcondrey
dcondrey / responsive-youtube-iframe.css
Last active Dec 17, 2018
Really responsive Youtube iFrame (width XOR height ) *Preview available here: https://www.thebouqs.com/en/content/8-how-it-works
View responsive-youtube-iframe.css
#hero { width:100%;height:100%;background:url('{$img_ps_dir}cms/how-it-works/hero.jpg') no-repeat top center; }
.videoWrapper { position:relative;padding-bottom:56.25%;padding-top:25px;max-width:100%; }
@media (min-width:1000px) {
#hero { background-size:cover; }
}
@media (max-width:767px) {
#hero { width:100%;height:94%!important;background:url('{$img_ps_dir}cms/how-it-works/hero-mobile.jpg') no-repeat top center;background-position: 0 -155px;height: 273px!important;background-position:0 -209px; }
}
@media (max-width:540px) {
@dcondrey
dcondrey / format-audio.php
Created Jul 19, 2014
Modify Wordpress Post Formats and display them as a horizontal tab bar along the top of the post editor page.
View format-audio.php
<div class="post-editor-block" id="post-editor-audio-fields" style="display: none;">
<label for="post-editor-audio-embed"><?php _e('Audio URL (oEmbed) or Embed Code', 'post-format'); ?></label>
<textarea name="_format_audio_embed" id="post-editor-audio-embed" tabindex="1"><?php echo esc_textarea(get_post_meta($post->ID, '_format_audio_embed', true)); ?></textarea>
</div>