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
#lang racket | |
;; A Contract is one of: | |
;; - Any -> Boolean | |
;; - Signature | |
;; A Signature is a (signature Contract Contract) | |
(struct signature (domain range)) | |
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
# A Contract is one of: | |
# - Proc (Any -> Boolean) | |
# - Hash { Contract => Contract } | |
def assert_predicate(predicate, value) | |
if predicate.(value) | |
value | |
else | |
fail "contract error" | |
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
#!/usr/bin/env ruby | |
require 'pry' | |
require 'json' | |
json = JSON.parse(`curl https://api.github.com/users/nixpulvis/repos?per_page=100`) | |
json.each do |repo| | |
if File.exists?(repo['name']) | |
Dir.chdir(repo['name']) | |
print "Pulling #{repo['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
.text | |
.global _start | |
_start: | |
movl $foo,%edx | |
movl $string,%ecx | |
movl $1,%ebx | |
movl $4,%eax | |
int $0x80 | |
movl $0,%ebx |
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
macro_rules! try_or { | |
($expr:expr => $handler:expr) => (match $expr { | |
::std::result::Result::Ok(v) => v, | |
::std::result::Result::Err(e) => { | |
warn!("{}", e); | |
$handler | |
} | |
}) | |
} |
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 |