Skip to content

Instantly share code, notes, and snippets.

function is_superman() {
return true;
}
function superman_inf() {
return "∞";
}
$(function () {
var titleunhover = function () {
$(this).find("a.title").next("a.censor").remove();
# Create a diagonal matrix given a vector (or an array), placing the entries
# of the vector on the diagonal of the matrix.
# For example, diag([1,2,3]) would give:
# [ 1 0 0 ]
# [ 0 2 0 ]
# [ 0 0 3 ]
# That would actually be a 2D matrix like this [[1, 0, 0], [0, 2, 0], [0, 0, 3]]
# The array returned has to be converted to a matrix by doing
# Matrix[ *diag(vector) ]
def diag(vector)
def generate_matrix(size)
Array.new(size) { Array.new(size) { rand 10 } }
end
# Only for 3x3 matrices for the time being
# Refactor!
def determinant(matrix)
(matrix[0][0] * ((matrix[1][1] * matrix[2][2]) - (matrix[2][1] * matrix[1][2]))) - (matrix[0][1] * ((matrix[1][0] * matrix[2][2]) - (matrix[2][0] * matrix[1][2]))) + (matrix[0][2] * ((matrix[1][0] * matrix[2][1]) - (matrix[2][0] * matrix[1][1])))
end
<%
## TODO: While refactoring, perform all calculations _out_ of this file.
# Function to easily give out something like "The reviewer noted the following: The board looks great!"
def noted(a, t)
t == '' ? '' : 'The reviewer ' + a + ' the following: ' + t
end
def yes
'[img]http://s242.photobucket.com/albums/ff244/9861_omikron/famfamfamsilk/accept.png[/img] '
var Rufus = {
Mnemo: {
/** CONSTANTS **/
V: [ 'a', 'e', 'i', 'o', 'u' ],
C: [ 'b', 'd', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'r', 's', 't', 'z' ],
SYL: [], // This is populated later on. [1]
SPECIAL: [
%w[
rubygems
sinatra
dm-core
dm-timestamps
].each { |lib| require lib }
get '/' do
"You aren't supposed to be viewing this."
end
@vikhyat
vikhyat / metronome.rb
Created April 22, 2009 05:32
Very simple metronome
#!/usr/bin/env ruby
def every(delay)
loop do
sleep(delay)
yield
end
end
def beep
class MyAwesomeClass
attr_accessor :awesome_instance_variable
def initialize(var)
@awesome_instance_variable = var
end
def reverse!
@awesome_instance_variable = @awesome_instance_variable.reverse
end
end
var jConsole = {
init: function() {
holder = document.createElement("div")
holder.setAttribute("style", "height: 250px; background: #000000; color: #ffffff; opacity: 0.4; position: static;")
document.body.appendChild(holder)
}
}
jConsole.init()