Skip to content

Instantly share code, notes, and snippets.

View BrendonKoz's full-sized avatar

BrendonKoz BrendonKoz

View GitHub Profile
@echo off
forfiles /p "\\server\Redirect" /m "Folder Name" /s /c "cmd /c del @file /Q"
@BrendonKoz
BrendonKoz / gist:df1e0fefedd237120872
Created August 4, 2014 20:26
Simple CKEditor custom load (with jQuery)
$(document).ready(function(){
$('textarea').ckeditor({
contentsCss: '/css/ckeditor_custom.css', //external CSS to set body{margin:0;}
uiColor: '#FFFFFF',
scayt_autoStartup: true, //spellcheck auto-enabled
autoGrow_onStartup: true,
enterMode: CKEDITOR.ENTER_BR, //I hate this but our users request it
removePlugins: 'elementspath, resize',
extraPlugins: 'autogrow,confighelper', //confighelper allows HTML5-like placeholder text
extraAllowedContent: 'img[alt,dir,id,lang,longdesc,!src,title]{*}(*)', //needed to allow image pasting without an image button
@BrendonKoz
BrendonKoz / PHPExcelHelper.php
Created October 21, 2014 03:23
A helper class to make creating robust, but simple Excel workbooks with PHPExcel even easier.
<?php
// import (and instantiate) the required 3rd party autoload class for all required classes
require_once('./path_to/PHPExcel.php');
// Call a member method that automatically guesses and assigns cell properties (Date, Number, Text, etc.)
PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );
class ExcelHelper {
@BrendonKoz
BrendonKoz / toggle_icons.au3
Created January 13, 2012 16:07
AutoIt Script to enable/disable (toggle on each run) the display of desktop icons on a Windows PC. Can be used to prevent users from clicking on programs before computer is fully loaded if run as a startup application (with a delayed timer).
Func PostMessage($hWnd, $msg, $wParm, $lParm)
Return DllCall("user32.dll", "int", "PostMessage", _
"hwnd", $hWnd, _
"int", $msg, _
"int", $wParm, _
"int", $lParm)
EndFunc ;==>PostMessage
$programManager = WinGetHandle("Program Manager");
PostMessage($programManager, 0x111, 28755, 0); Show/Hide desktop icons (0x0111 is defined as $WM_COMMAND in GUIConstants.au3)
@BrendonKoz
BrendonKoz / polaris_to_wordpress.php
Created August 14, 2012 17:33
Script to parse a Polaris Library Systems' exported XML report of a record set in order to dynamically post to a (pre-installed) Wordpress site (as a blog post). XMLRPC must be enabled in WP Settings. Was used for monthly "new materials" posts. Adapt to y
<?php
$username = 'your_wp_username';
$password = 'your_wp_password';
$blogURI = 'http://www.example.com/wordpress/';
$ignored_categories = array('Blogroll'); //store categories to ignore in an array for easier blocking
$blogAPI = $blogURI . 'xmlrpc.php';
$data = array();
$publish = false;
@BrendonKoz
BrendonKoz / sleep.bat
Created September 7, 2012 19:21
Set a WinXP Computer to Sleep via a command line call
@echo off
cls
rundll32.exe powrprof.dll,SetSuspendState Sleep
exit
@BrendonKoz
BrendonKoz / 2k3_backup.bat
Created September 7, 2012 19:30
Run Windows 2k3 Server backup from batch file
REM runs a "One-Time Backup" to specific target drive from batch file
REM ...create your own backup schedule instead of Microsoft's "Windows Server Backup" forced schedules
WBADMIN START SYSTEMSTATEBACKUP -backupTarget:e: -quiet
<?php
/**
* Convert RGB colors array into HSL array
*
* @param array $ RGB colors set
* @return array HSL set
*/
function rgb_to_hsl($color){
list($r, $g, $b) = is_array($color) ? $color : hex_to_rgb($color);
@BrendonKoz
BrendonKoz / bk_autoupdate.php
Created December 22, 2015 17:57
"MUST USE" plugin. Place in wp-content/mu-plugins to assure automatic theme & plugin updates are happening.
<?php
/*
Plugin Name: Theme and Plugin Auto-Update
Description: Forces automatic updates of installed plugins and themes. Be sure to have backups running!
Version: 1.0
Author: Brendon Kozlowski
Author URI: http://www.bytekick.com
License: MIT
*/
<?php
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test Image Preview Pre-Upload</title>
<style type="text/css">
form div.upload label { font-weight:bold; display:block; margin-bottom:0.25em; }
img.file-preview { border:3px solid #000; }