This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class ATree { | |
Rational value; | |
ATree(Rational value){ | |
this.value = value; | |
} | |
abstract Node expandOneLevel(); | |
// returns the integer value of the node/leaf | |
public Double doubleValue(){ | |
return this.value.toDouble(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tester.Tester; | |
class Star { | |
String name; | |
Movie movie; | |
Star(String name){ | |
this.name = name; | |
} | |
Star(String name, Movie movie){ | |
this.name = name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- converts hex colors to 0-1 colors for use in World of Warcraft. | |
function V.HexToColor(hex) | |
local color = { } | |
if strlen(hex) == 6 or strlength(hex) == 8 then | |
for i = 1, 8, 2 do | |
if strsub(hex, i, i+1) == "" then print(strsub(hex, i, i+1)) break end | |
-- converting string to number 0-1 | |
tinsert(color, tonumber(strsub(hex, i, i+1), 16)/255) | |
end | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mover:SetScript("OnDragStart", function() | |
local lastX, lastY = GetCursorPosition() | |
mover:SetScript("OnUpdate", function() | |
local x, y = GetCursorPosition() | |
xOff, yOff = x-lastX, y-lastY | |
lastX, lastY = x, y | |
for i = 1, frame:GetNumPoints() do | |
local point, relativeTo, relativePoint, xOffset, yOffset = frame:GetPoint(i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# returns an array of files that are required by the given file | |
def get_requirements( file ) | |
requirements = Array.new | |
File.readlines("#{file}.rb").each do |line| | |
regex = /(?<=require.')(.*)(?=';)/ # matches the requirements in a file | |
requirement = line.match(regex) | |
if requirement | |
requirements << requirement.to_s | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.markdown { | |
body { | |
font-family: Helvetica, arial, sans-serif; | |
font-size: 14px; | |
line-height: 1.6; | |
padding-top: 10px; | |
padding-bottom: 10px; | |
background-color: white; | |
padding: 30px; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sieve( n ) | |
s = (2..n).to_a | |
s.each { |p| next unless p; break if p**2 > n; (p**2).step(n, p) { |m| s[m-2] = nil } } | |
s.compact | |
end | |
def time | |
start = Time.now | |
yield | |
Time.now - start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum += e *= month_days[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# ## An Easy Way to Compile and Run Java Classes | |
# | |
# System utility for compiling and running Java classes | |
# in a specific directory structure. | |
# | |
# #### Recommended Installation | |
# Save this code to a file named `easyjava`, somewhere on your HD. Then | |
# in your `~/.bash_profile` add the following: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void assertEquals (String name, Object a, Object b) { | |
if (! a.equals(b)) { | |
System.out.println ("***** Test failed ***** " | |
+ name + ": " + totalTests); | |
System.out.println (" A => " + a); | |
System.out.println (" b => " + b); | |
totalErrors = totalErrors + 1; | |
} | |
totalTests = totalTests + 1; | |
} |
OlderNewer