Skip to content

Instantly share code, notes, and snippets.

View mrspeaker's full-sized avatar

Mr Speaker mrspeaker

View GitHub Profile
@mrspeaker
mrspeaker / index.html
Created October 18, 2010 13:27
Code for the Global Composite Operation podcast
<!DOCTYPE html>
<html lang="en">
<head>
<title>Global Composite Operation</title>
<link rel="stylesheet" href="venn.css" type="text/css">
</head>
<body>
<div id="container">
<p>Canvas Global Composite Operation</p>
<canvas id="venn" width="1000" height="600"></canvas>
@mrspeaker
mrspeaker / typed.js
Created November 23, 2010 12:22
JavaScript typed array on iOS 4.2.1
<script type="text/javascript" charset="utf-8">
var buffer = new ArrayBuffer( 16 );
var int32View = new Int32Array( buffer );
for ( var i = 0; i < int32View.length; i++ ) {
int32View[i] = i * 2;
}
alert( int32View[ 3 ] ); // Alerts 6 in 4.2.1
</script>
@mrspeaker
mrspeaker / oadingL.css
Created January 22, 2011 22:14
oadingL: The Magnificent Marquee Throbber
#oadingL, #oadingL marquee {
font-size:1px;
-moz-border-radius:16px;
-webkit-border-radius:16px;
border-radius:16px;
}
@mrspeaker
mrspeaker / cache.manifest
Created January 25, 2011 10:14
Demo files for "flash card" app demonstrating HTML5 offline cache manifest. Full repo at https://github.com/mrspeaker/Eng2Fr
CACHE MANIFEST
# v0.1
index.html
lib/jquery-1.4.4.min.js
main.css
main.js
images/eng2fr.png
@mrspeaker
mrspeaker / script.js
Created January 26, 2011 12:48
Killa! #parisjswar
http://img.brothersoft.com/icon/softimage/0/2004_top_tank-27153.jpeg
onRobotScanned: function(enemy) {
var angle = enemy.bearing - this.gunBearing
angle = angle < -180 ? 360 + angle : angle
this.turnGunRight(angle)
this.state = 'lock'
if(Math.abs(angle) <= 1 && this.energy > 10) {
this.fire(enemy.velocity < 1 ? 4 : 1)
}
@mrspeaker
mrspeaker / index.html
Created April 27, 2011 12:58
Collection mapping test: jQuery vs jQuery vs JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Collection mapping: jQuery vs jQuery vs JavaScript</title>
</head>
<body>
<h1>Comparing Maps</h1>
<h2>jQuery vs jQuery vs JavaScript</h2>
<p>Output is in the JavaScript console.</p>
<p>For more info, view source (or visit <a href="http://www.mrspeaker.net/2011/04/27/reducing-map/">Mr Speaker's "reducing map"</a>)
@mrspeaker
mrspeaker / plus.google.com.js
Created July 25, 2011 15:09
dotjs script to limit Google+ posts to 80px high
/*
Make Google+ like Twitter. So, you know, it's useful.
by Mr Speaker
Limits post size to 80px high.
Double click to expand/contract.
Relies on jQuery (included by default with dotjs)
*/
(function AddStylez() {
@mrspeaker
mrspeaker / README
Created November 2, 2011 11:04
AI Class playlist generator
These are the scripts I use to create the playlists for the AI Class (available here: http://www.mrspeaker.net/2011/10/26/ai-class-playlists/). It's not pretty, but it works. I put them up here due to popular demand.
The first stage is to grab the video list HTML from YouTube and extract/sort the videos. This is done with the Video_ID_scraper.html file (instructions there).
Next, paste the video info into the YouTube_Playlist_Uploader.py script and it generates the playlist. It relies on the GData APIs so you need a dev key etc.
Any questions to mrspeaker@gmail.com
@mrspeaker
mrspeaker / pseudo-code.java
Created March 5, 2012 13:56
Why does Notch check X and Y separately in the collision detection routine?
/*
After watching a few of Notch's (and Mojan's) "write a game in a weekend" livecasts and
pulling apart some of the code (http://www.mrspeaker.net/2011/12/30/colorising-sprites-1/)
I've noticed that the collision detection routines are broken into two methods - usually
called "move" and "move2".
The move method gets the amount the entity will move on the X axis and calls
move2 with move2(x, 0). Then the same thing is done with the Y: move2(0,y).
Why would this be necessary? I've broken the code down into pseudo code to see if I