Skip to content

Instantly share code, notes, and snippets.

<?php
preg_match_all('/<img src="([^"]+)_SM.jpg"/i', file_get_contents($argv[1]), $matches);
foreach ($matches[1] as $key => $match)
{
$infile = $match.'_BG.jpg';
if ($data = file_get_contents($infile))
{
#!/usr/bin/env php
<?php
# execute as nightly cronjob
# redirect to /dev/null if you don't want get mailed errors because WoW is running
# use with Elephant (or similar) addon that automatically enables writing to WoWChatLog.txt
$source_path = "/Applications/Games/World of Warcraft/Logs";
$dest_path = '/Users/david/Documents/Logs/WoW';
<?php
/**
* reorders an array based on the specified order of keys.
*
* @param array $array the array that should be reordered
* @param array $order the order that the keys in the first array should be in. each value should be a key from the first array. any elements from the first array that are not specified in the order will be inserted at the end of the returned array, in their original order.
*
* @return array
*/
#!/usr/bin/env bash
# config
date=`date "+%Y-%m-%d"`
git_binary=/usr/local/bin/git
# repositories in /git, space-separated.
repos="foo.git bar.git"
<?php
/**
* get current git revision
*/
if (sfConfig::get('sf_environment') != 'prod' && file_exists(sfConfig::get('sf_root_dir').'/../.git/logs/HEAD'))
{
$fp = fopen(sfConfig::get('sf_root_dir').'/../.git/logs/HEAD', 'r');
$pos = -2; $line = ''; $c = '';
#!/bin/bash
# Apple has informed me that you should not use Time Machine for backing up a server.
# (Why it remains an option in System Preferences, despite not working correctly, is a mystery to me.)
# For further information, see Advanced_Server_Admin_v10.6.pdf, page 36.
# If you still want this script for some reason, see past revisions.
#!/usr/bin/env bash
for type in markdown md
do
for file in *.$type
do
if [ -f $file ]
then
if [ ! -d "markdown2html" ]
then
#!/bin/bash
# Problem: DirectoryService crashes randomly. When this happens, AFP stops working until AFP is restarted.
#
# Workaround: This script looks for DirectoryService crashes, and upon detecting one, restarts AFP.
#
# Installation: Move this script to /usr/local/bin (or desired location) and chmod +x. Add to system crontab, run as root. I recommend running every minute to minimize AFP downtime, but the syslog command can be very resource-intensive, so it is ultimately at your discretion.
notify_email="[email protected]"
last_restart_file="/var/run/directoryservice_check_crash"
/**
* thanks to Mark Pilgrim:
* http://diveintohtml5.org/everything.html
* http://diveintohtml5.org/detect.html#techniques
*/
function check_html5_audio()
{
// avoid repeating the check unnecessarily
if (typeof browser_supports_html5_audio != "undefined")
{
<?php echo '<?'; ?>xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
<title>
<?php echo ucwords(basename(dirname($_SERVER['SCRIPT_NAME']))); ?><?php if (!empty($_GET['match'])): ?> : <?php echo ucwords($_GET['match']); ?><?php endif; ?>
</title>
<?php $files = scandir('.'); ?>
<?php $files = array_reverse($files); ?>