Skip to content

Instantly share code, notes, and snippets.

View artlung's full-sized avatar
💭
🤖

Joe Crawford artlung

💭
🤖
View GitHub Profile
@artlung
artlung / monte_carlo.py
Created May 19, 2010 00:30
Monte Carlo Python Program
"""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
<?php
// Add this to functions.php in your theme to allow youtube
// video shortcodes like wordpress.com does:
// http://en.support.wordpress.com/videos/youtube/
function youtube_shortcode_func($atts) {
extract(shortcode_atts(array(
'youtube' => '',
), $atts));
$url = $atts[0];
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVQAAAECCAIAAAAuJ7gIAAAWIGlDQ1BJQ0MgUHJvZmlsZQAAeAHVWGdUFMGy7tnMBthlyXGJS84ZyVlAcg6Sc44CIoiIJFGCSBRBFBBERSUYCSZUFAygggoiAoKKgoDEN+i74Z3z7r/359U50/1Nd29tT1fN1FcFAPuSd1RUGIIMQHhEXIytiT7N2cWVhn0LUAABiEADaHr7xkbpWVtbgP8oy8MA2pl8Ib2j6z8u+98nKH7+sb4AQNbwtI9frG84jK/C2MI3KiYOwJuAZTAxLmoHD8KYJQbeIIw/7eDAv3h1B/v8wUjinzX2tgYAIGkA4Ije3jGBABCk4HFagm8grIcAPwuGOcIvOAIAiheMtX2DvP0AYD8Nr5EKD4/cwU9gLObzb3oC/w17e/v8U6e3d+A/8d9ngX8J/7FhcGxUmHfSn5v/yyY8LB4+rz+yczhE/wgHO7hnhi8x/1ijf2ANYAAiQRh8xQAasIDvDP+7pQHff8zE+e+DzwMAg8iopJjgwKA4mh5sQX8pmlmEr4wUTUFOXm5n+v+N7Pju380u2v7xSYjt2b/G9uoDoLwJ23vmX2PhXwG4dBgAbql/jYmfA4AzFYDLnL7xMQl/9aF2OjTAAybAAjgBHxACYkAaKAAVoAl0gRHYDayAPXABnvDpBoFw+NQTwX5wEGSBPHAcnAAVoAacAY3gAmgDHeAm6AH3wWMwCF6BUTAOpsAcWADLYB2CICxEgqgQJ8QPiUCSkAKkBmlDRpAFZAu5QF5QIBQBxUP7oUNQHlQEVUC1UBN0GeqCeqB+aAh6A01As9BPaA2BRBARLAhehChCFqGG0EOYI+wRHohARDQiGZGJKECUIeoQLYh2RA/iMeIVYhwxh/iFBEgCkg0pgJRGqiENkFZIV2QAMgZ5AJmLLEXWIVuR15EPkC+Q48h55G8UBkVF0VDSKE2UKcoB5YuKRh1A5aMqUI2odtRd1AvUBGoBtY
img.alignright {float: right;margin: 0 0 1em 1em;}
img.alignleft {float: left;margin: 0 1em 1em 0;}
img.aligncenter {display: block;margin-left: auto;margin-right: auto;}
a img.alignright {float: right;margin: 0 0 1em 1em;}
a img.alignleft {float: left;margin: 0 1em 1em 0;}
a img.aligncenter {display: block;margin-left: auto;margin-right: auto;}
<html>
<head>
<title>Cursor Position Radius</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<style type="text/css" media="screen">
#square {
height: 400px;
width: 400px;
background-color: #000;
margin: auto;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<base href="http://heavylungs.tumblr.com/" />
<meta name="color:background" content="#FAFAFA" />
<meta name="color:box" content="#FFFFFF" />
<meta name="color:title" content="#919191" />
<meta name="color:text" content="#6F6F6F" />
<meta name="color:link" content="#aaaaaa" />
@artlung
artlung / exp.html
Created July 11, 2010 23:14
Math function that is self-reflective
<script src="exp.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
// alert(ALL.plus(1).minus(5).dividedBy(2).times(1000));
alert(ALL.equals(2).toThePowerOf(2).dividedBy(2).plus(100).plus(234).times(3).dividedBy(5));
alert(ALL.getLog());
// alert(typeof ALL.getLog)
</script>
@artlung
artlung / insta-tracker.php
Created July 14, 2010 15:31
Get notifications when page visited.
<?php
// add ip addresses you don't care about here
$no_mail = array(
'24.254.148.80',
'67.145.115.105',
'207.46.149.50',
);
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI';
$to_email = 'me@example.com';
if (!in_array($_SERVER['REMOTE_ADDR'], $no_mail)):
body {
scrollbar-arrow-color: black;
scrollbar-face-color: #e7e7e7;
scrollbar-3dlight-color: #a0a0a0;
scrollbar-darkshadow-color: #888888;
}
@artlung
artlung / disable-tulsaworld-copy-event.user.js
Created August 24, 2010 02:02
disable-tulsaworld-copy.user.js
// ==UserScript==
// @include http://www.tulsaworld.com/*
//
var divs = document.getElementsByTagName('div');
// for each div
for (var i=0;i<divs.length;i++) {
var div = divs[i];
// that has the text "divArticleText" in the id
if (div.getAttribute('id') && div.getAttribute('id').indexOf('divArticleText') !== -1) {
// give it a whole new unique name