Skip to content

Instantly share code, notes, and snippets.

@cormacrelf
cormacrelf / moregraphs
Created March 18, 2012 02:51
moregraphs
var canvas = document.getElementById('c');
canvas.width = 600;
canvas.height = 600;
var ctx = canvas.getContext('2d');
var draw = function(x,y){
ctx.fillRect(x,600-y,1,1);
};
ctx.fillRect(300,0,1,600);
@cormacrelf
cormacrelf / graph
Created March 18, 2012 01:16
graphing
function Graph(config){
this.canvas = config.canvas;
this.minX = config.minX;
this.minY = config.minY;
this.maxX = config.maxX;
this.maxY = config.maxY;
this.context = this.canvas.getContext("2d");
this.centerY = Math.abs(this.minY / (this.maxY - this.minY)) * this.canvas.height;
this.centerX = Math.abs(this.minX / (this.maxX - this.minX)) * this.canvas.width;
function Animal() {
this.eyes = 2;
this.legs = 4;
this.name = "Animal";
this.mutate = function () {
this.eyes += 1;
this.legs += 1;
this.name = this.name + "...";
};
}
@cormacrelf
cormacrelf / prototypes.js
Created March 3, 2012 05:06
Prototypical inheritance
function Foo() {
this.meaningOfLife = 42;
this.hasOwnProperty = function() {
return false;
};
}
Foo.prototype = {
wat: function() {
return Array(16).join("wat" - 1) + " Batman!";
@cormacrelf
cormacrelf / dates
Created February 25, 2012 12:11
You know those people who can tell you the weekday for any date? Here's how to practise that. Tip: 0 means Sunday through to 6 means Saturday when talking about "weekday codes". Grey Matters' guide might help you, too: http://gmmentalgym.blogspot.com.au/
#!/usr/bin/env ruby
require 'date'
require "highline/import"
begin
class Date
def pretty_string
months = [ nil,"January", "Febuary",
"March","April","May",
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
// switch the protocol to "https:// to enforce a SSL connection
var protocol = "http://";
//var protocol = "https://";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<div align="center">
<font face="Arial, Helvetica, sans-serif" color="#003366" size="2">
<font size="2" face="Arial">
Put anything you want in here. Mr Bowen forgot a <noscript></noscript> tag. Even log people's credentials using an event listener on the form. ANYTHING. Then test using this preview or put it into the page source's real div. Go for it.
* Embed a rickroll video
* Tweet how crap this webpage is
* Insert an ad for ALT-LP developed by yours truly and JP
@cormacrelf
cormacrelf / keybindings.zsh
Created February 1, 2012 04:21
keybindings
bindkey -v
bindkey "^P" vi-up-line-or-history
bindkey "^N" vi-down-line-or-history
bindkey "^A" beginning-of-line
bindkey "^E" end-of-line
bindkey "^H" backward-delete-char
bindkey "^U" backward-kill-line
bindkey "^?" backward-delete-char
bindkey "^[[2~" beep
bindkey "^[[5~" vi-backward-blank-word
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by tmux configure 1.6, which was
generated by GNU Autoconf 2.65. Invocation command line was
$ ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/tmux/1.6 --sysconfdir=/usr/local/etc
## --------- ##
## Platform. ##
@cormacrelf
cormacrelf / gist.txt
Created January 30, 2012 08:07
brew install -v tmux
==> Downloading http://sourceforge.net/projects/tmux/files/tmux/tmux-1.6/tmux-1.6.tar.gz
File already downloaded in /Users/cormac/Library/Caches/Homebrew
/usr/bin/tar xf /Users/cormac/Library/Caches/Homebrew/tmux-1.6.tar.gz
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/tmux/1.6 --sysconfdir=/usr/local/etc
./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/tmux/1.6 --sysconfdir=/usr/local/etc
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... etc/install-sh -c -d
checking for gawk... no
checking for mawk... no