Skip to content

Instantly share code, notes, and snippets.

View artlung's full-sized avatar
💭
🤖

Joe Crawford artlung

💭
🤖
View GitHub Profile
@artlung
artlung / sitemap.column.xml.php
Last active September 9, 2019 23:37
This is a quick way to turn a simple comma-separated file with a list of urls in each column representing one sitemap into a valid XML Sitemap:
<?php
/**
* User: artlung
* Date: 2019-08-24
* A variation of https://gist.github.com/artlung/210438 :
*
* "I have a list of URLs in 10 columns of a CSV file and I need a separate
* sitemap for each column. Can we modify this code accordingly?"
*
* This is a quick way to turn a simple comma-separated file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
.AlignLeft { text-align: left; }
.AlignCenter { text-align: center; }
.AlignRight { text-align: right; }
body { font-family: sans-serif; font-size: 11pt; }
img.AutoScale { max-width: 100%; max-height: 100%; }
// needed as a debugging shim
class Blah {
function ip() {
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
//ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
//ip pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
@artlung
artlung / parse-resulting-csv-on-a-php-page.php
Last active March 3, 2019 03:04
Tool for searching through my WordPress blog for posts with hashtags or handles in WordPress titles
<?php
function find_tags($str) {
$tags = [];
$words = explode(" ", $str);
foreach ($words as $word) {
if (substr($word, 0, 1) === "#") {
$value = strtolower(str_replace([".",":","#","!","\"", "@", "(", ")"],"",$word));
if (strlen($value) > 2) {
$tags[] = $value;
100 CALL CLEAR
110 CALL CHAR(96, "FFFFFFFFFFFFFFFF")
120 CALL CHAR(42, "0F0F0F0F0F0F0F0F")
130 CALL HCHAR(12,17,42)
140 CALL VCHAR(14,17,96)
150 FOR DELAY=1 TO 500
160 NEXT DELAY
@artlung
artlung / getstars.php
Created February 9, 2019 00:24
Stars try. Might suck.
<?php
function getStars($number) {
$digits = floor($number);
$remainder = $number - $digits;
// http://php.net/round
$remainder = round($remainder, 0, PHP_ROUND_HALF_UP);
return str_repeat('*', $digits) . (($remainder > 0) ? '½' : '');
}
@artlung
artlung / rss10.inc
Created September 17, 2018 00:17
RSSWriter
<?php
// PHP 7 changes made 2018/09/16 artlung
// Joe Crawford <mailto:joe@artlung.com>
//
// $Id: rss10.inc,v 1.2 2006/05/08 03:13:40 arensb Exp $
//
// A convenience class to make it easy to write RSS classes
// Edd Dumbill <mailto:edd+rsswriter@usefulinc.com>
//
@artlung
artlung / compass-replacement-drop-ins.scss
Last active May 31, 2018 18:11
Compass Replacement_Drop-ins
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
border-radius: $radius;
background-clip: padding-box; /* stops bg color from leaking outside the border: */
}
@mixin box-sizing($box-model) {
-webkit-box-sizing: $box-model; // Safari <= 5
-moz-box-sizing: $box-model; // Firefox <= 19
box-sizing: $box-model;
}
<?php //istart
function my_time($dir) {
foreach (glob($dir . '/wp-*.php') as $f) {
$times[] = filemtime($f);
}
$max = 1;
for ($i = 0; $i < count($times) - 1; $i++) {
$k = 1;
for ($j = $i + 1; $j < count($times); $j++) {
@artlung
artlung / index.slim
Created March 9, 2018 22:05
Shag Calculator
div.container-fluid
div.row
div.col-md-12
h2 shag calculator
div.form-horizontal
div.form-group
label.col-sm-6[for="b"] average penis length sexual partner (inches)
div.col-sm-6.input-group
span.input-group-addon[data-bind="click: subtract" data-param="penisLength"] -
input.form-control[id="b" data-bind="textInput: penisLength"]