Skip to content

Instantly share code, notes, and snippets.

💭
🤖

Joe Crawford artlung

💭
🤖
View GitHub Profile
@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 / highlight-dow-jones-changes-2020.js
Last active Jun 26, 2020
Use this on the Wikipedia page for "List of largest daily changes in the Dow Jones Industrial Average"
View highlight-dow-jones-changes-2020.js
var tds = document.querySelectorAll('td');
// Use in the console for https://en.wikipedia.org/wiki/List_of_largest_daily_changes_in_the_Dow_Jones_Industrial_Average
for (var i = 0; i<tds.length; i++) {
var td = tds[i];
if (td.innerText.indexOf('2020-0') === -1) {
td.style.opacity = 0.3;
td.style.backgroundColor = td.style.backgroundColor.toString().replace(')', ',0.3)');
}
}
@artlung
artlung / jquery-example.html
Created May 1, 2010
A simple hello world jQuery example
View jquery-example.html
<html>
<head>
<title>My Sample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var new_num = 40; // global variable
jQuery(document).ready(function(){
http://api.jquery.com/css/
$('p').css({border: '5px solid red', color: 'green', padding: '20px'});
@artlung
artlung / smiley.html
Created Sep 7, 2010
Make a smiley face using only css+html
View smiley.html
<html>
<head>
<title>smiley</title>
<style type="text/css">
body {
font-family: helvetica, sans-serif;
}
div#wrapper {
width: 100px;
padding: 50px;
View sitemap-siteindex.php
<?php
/**
*
* This is a quick way to turn a simple text file
* with a very long list of urls in a text file (sitemap-urls.txt)
* Where "very long" is an expected url number greater than 10,000
* If loaded without a valid query parameter "page" it will load a
* Site Index site map, otherwise load the individual XML site map
* 10,000 urls into a valid XML Sitemap:
* http://en.wikipedia.org/wiki/Sitemaps
@artlung
artlung / sitemap.column.xml.php
Last active Sep 9, 2019
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:
View sitemap.column.xml.php
<?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
View Report.html
<!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%; }
View ventcheck_bot.json
{
"adjectives" : ["aback","abaft","abandoned","abashed","aberrant","abhorrent","abiding","abject","ablaze","abnormal","aboard","aboriginal","abortive","abounding","abrasive","abrupt","absent","absorbed","absorbing","abstracted","absurd","abusive","acceptable","accessible","accidental","accurate","acoustic","acrid","actually","ad","hoc","adamant","adaptable","addicted","adhesive","adjoining","adorable","afraid","agonizing","ahead","alcoholic","alert","alike","alive","alleged","alluring","aloof","ambiguous","ambitious","amuck","ancient","animated","apathetic","aquatic","aromatic","aspiring","assorted","astonishing","auspicious","available","average","aware","axiomatic", "bad","barbarous","bashful","bawdy","beautiful","befitting","belligerent","berserk","better","big","billowy","bizarre","black","boiling","boorish","boring","boundless","brash","brawny","breezy","brief","bright","broad","broken","bumpy","burly", "cagey","callous","capable","capricious","ceaseless","changeable","cheerful","childlike","chilly","chi
@artlung
artlung / monte_carlo.py
Created May 19, 2010
Monte Carlo Python Program
View monte_carlo.py
"""Run a Monte Carlo simulation to validate the lottery example."""
import random
from lottery import winner, PEOPLE
def simulate(runs, f=winner, arg=PEOPLE):
"""Simulate function f with argument arg with number of given runs."""
# Store the number of results in a dict.
result_counts = {} # this is a dict
View Blah.php
// 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{
You can’t perform that action at this time.