Skip to content

Instantly share code, notes, and snippets.

😴
= (λx.x x)(λx.x x)

Nathan Lilienthal nixpulvis

😴
= (λx.x x)(λx.x x)
View GitHub Profile
@nixpulvis
nixpulvis / quest1.java
Created Jan 30, 2012
infinate set (countability of rational numbers)
View quest1.java
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();
@nixpulvis
nixpulvis / gist:1926289
Created Feb 27, 2012
Simple Ciclic Data
View gist:1926289
import tester.Tester;
class Star {
String name;
Movie movie;
Star(String name){
this.name = name;
}
Star(String name, Movie movie){
this.name = name;
@nixpulvis
nixpulvis / Hex -> Color
Created May 17, 2012
This if a function to convert hex strings into r, g, b color. This function returns multiple variables.
View Hex -> Color
-- 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
@nixpulvis
nixpulvis / gist:2779607
Created May 24, 2012
repositioning from child
View gist:2779607
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)
@nixpulvis
nixpulvis / gist:2890564
Created Jun 7, 2012
Dynamic content require (for interpreted languages)
View gist:2890564
# 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
@nixpulvis
nixpulvis / markdown.less
Created Jul 11, 2012 — forked from andyferra/github.css
Github Markdown CSS - for Markdown Editor Preview
View markdown.less
.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; }
View sieve.rb
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
@nixpulvis
nixpulvis / chain_assignment.rb
Created Aug 21, 2012
Sexy Chain Assignment
View chain_assignment.rb
sum += e *= month_days[i]
@nixpulvis
nixpulvis / easyjava
Created Sep 10, 2012
Simple and Easy way to run a java class.
View easyjava
#!/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:
@nixpulvis
nixpulvis / gist:3763424
Created Sep 21, 2012
quick and dirty assertEquals
View gist:3763424
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;
}
You can’t perform that action at this time.