Skip to content

Instantly share code, notes, and snippets.

<%
## 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] '
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
# 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)
function is_superman() {
return true;
}
function superman_inf() {
return "&#8734;";
}
$(function () {
var titleunhover = function () {
$(this).find("a.title").next("a.censor").remove();
@vikhyat
vikhyat / velox.rb
Created April 17, 2010 09:57
Source code for vikhyat.net/stuff/velox/
<html>
<head>
<title>Velox: Random Latin Words</title>
<style type="text/css">
p {
font-family: Georgia,Palatino,Times,'Times New Roman',sans-serif;
}
a:link, a:visited {
color: #f30;
font-size: 75%;
5 3
7 4
5 3
10 1
7 4
6 2
2 2
2 1
1 1
13 13
@vikhyat
vikhyat / priority_queue.rb
Created September 20, 2010 10:37
naive priority queue implementation
class PriorityQueue
def initialize
@pq = []
@sorted = true
end
def push(object, priority)
@pq << [ object, priority ]
@sorted = false
end
groove_fanatics:boolean
synchronians:boolean
synchronians_group_name:string
charlie_madchap:boolean
charlie_madchap_group_name:string
band_slam:boolean
band_slam_group_name:string
alaap:boolean
instrumania:boolean
instrumania_instrument_name:string
@vikhyat
vikhyat / gist:4433910
Last active December 10, 2015 12:28 — forked from anonymous/gist:4433857
class AgendaTableViewController < UITableViewController
def tableView(tableView, numberOfRowsInSection:section)
return 10
end
def tableView(tableView, cellForRowAtIndexPath:indexPath)
tableView.dequeueReusableCellWithIdentifier('test') ||
UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier:'test')
end
require 'auth/oauth2_authenticator'
class HummingbirdAuthenticator < ::Auth::OAuth2Authenticator
CLIENT_ID = 'removed'
CLIENT_SECRET = 'removed'
def register_middleware(omniauth)
omniauth.provider :hummingbird, CLIENT_ID, CLIENT_SECRET
end