Skip to content

Instantly share code, notes, and snippets.

View artlung's full-sized avatar
💭
🤖

Joe Crawford artlung

💭
🤖
View GitHub Profile
@artlung
artlung / sitemap.xml.php
Created October 14, 2009 21:42
Generate XML sitemap from list of urls
<?php
/**
*
* This is a quick way to turn a simple text file
* with a list of urls in a text file (sitemap-urls.txt)
* into a valid XML Sitemap:
* http://en.wikipedia.org/wiki/Sitemaps
* Put this file sitemap.xml.php and sitemap-urls.txt at
* the webroot http://example.com/sitemap.xml.php
@artlung
artlung / DHTML.js
Created May 29, 2024 01:36
I do not miss this.
function show(object,x,y) {
if (document.all && document.all[object]) {
document.all[object].style.left = x+'px';
document.all[object].style.top = y+'px';
document.all[object].style.zIndex = AlwaysTopmostZ;
document.all[object].style.color = '#000';
AlwaysTopmostZ++;
document.all[object].style.visibility = 'visible';
}
else if (document.layers && document.layers[object] != null) {
<?php
/*
Plugin Name: Customize Feed Content
Description: I'm looking for a theme-independent plug-in that will let me customize my blog post excerpts for my RSS feed. I would like to be able to show the featured image and customize the length of the preview, as well as add a link underneath the excerpt for a viewer to click on to see the original article.
Version: 1.0
Author: artlung
*/
class CustomizeFeedContent {
/**
@artlung
artlung / happyscribe.com_molly_white_interview_transcript.txt
Last active May 23, 2024 18:37
Entering a New Phase of the Web, with Citation Needed’s Molly White https://about.flipboard.com/inside-flipboard/molly-white/
(Transcript made with HappyScribe.com)
[ NOTE: NOT FULLY COPYEDITED ]
https://about.flipboard.com/inside-flipboard/molly-white/
[00:00:02.240] Welcome to Dotsocial, the first podcast to explore the
world of decentralized social media. Each episode, host Mike McHieu
talks to a leader in this movement, someone who sees the Fediverse's
tremendous potential and understands that this could be the internet's
<?php
$current_dir = dirname(__FILE__);
// load wordpress functions
require_once( $current_dir . '/../../../wp-load.php');
$years = range(2001, date('Y'));
$ignored_permalinks = [
'https://artlung.com/blog/2002/02/02/9309543/',
<!--
A div with an id of 'slideshow' contains five images, the first of which is shown and the others are hidden using a display style of none. Using Javascript, create a simple slideshow that cycles through the images, displaying each image for three seconds at a time, looping back to the first image when the end is reached. You cannot use jQuery or any other library.
-->
<body>
<div id="slideshow">
<img src="http://placehold.it/300x200&text=foo1.jpg">
<img src="http://placehold.it/300x200&text=foo2.jpg" style="display: none">
<img src="http://placehold.it/300x200&text=foo3.jpg" style="display: none">
<img src="http://placehold.it/300x200&text=foo4.jpg" style="display: none">
<img src="http://placehold.it/300x200&text=foo5.jpg" style="display: none">
@artlung
artlung / renumber-primary-keys.sql
Created January 22, 2010 20:11
Renumber the keys of MySQL table
-- Let's say you had a table fruit
CREATE TABLE IF NOT EXISTS `fruit` (
`id` int(11) NOT NULL auto_increment,
`blah` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
);
-- Then you populate it, and delete some rows:
-- id, blah
@artlung
artlung / excerpt.php
Created March 12, 2024 18:46
Yet another PHP excerpt function
/**
* @param $text
* @param int $maxLength (default 200 characters)
* @param string $ending (characters to append to the end of the excerpt)
* @return string
*/
function excerpt($text, int $maxLength = 200, string $ending = '...'): string
{
// collapse whitespace
$text = preg_replace('/\s+/', ' ', $text);
@artlung
artlung / update-wp-links-with-rss.php
Created March 7, 2024 07:19
UPDATE WORDPRESS LINKS DATABASE WITH FEED URLS via COMMAND LINE
@artlung
artlung / RoanokeVisualization.php
Last active March 4, 2024 07:39
ArtLung Blog "Roanoke" WordPress Theme Blog Visualization Shortcode. Not packed as a plugin, would need to be modified to add to your blog. I may at some point package it up into a plugin form but feel free to extend, modify, share.
<?php
/**
* Class RoanokeVisualization
* Creates a visualization of blog posts by year and month
* and breaks out posts, and posts with Instagram and Delicious tags
*
* Uses wp_get_archives to get the data
* Uses wp_cache to store the data from expensive operations
*