Skip to content

Instantly share code, notes, and snippets.

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

Nathan Lilienthal nixpulvis

😴
= (λx.x x)(λx.x x)
Block or report user

Report or block nixpulvis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nixpulvis
nixpulvis / contract.rkt
Last active Aug 29, 2015
Simplest Contract System
View contract.rkt
#lang racket
;; A Contract is one of:
;; - Any -> Boolean
;; - Signature
;; A Signature is a (signature Contract Contract)
(struct signature (domain range))
@nixpulvis
nixpulvis / contract.rb
Created Apr 4, 2015
Simplest Contract System in Ruby
View contract.rb
# 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
@nixpulvis
nixpulvis / clone.rb
Created Jun 13, 2015
Clone/Pull All Repositories From GitHub
View clone.rb
#!/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']}... "
View hello_world.s
.text
.global _start
_start:
movl $foo,%edx
movl $string,%ecx
movl $1,%ebx
movl $4,%eax
int $0x80
movl $0,%ebx
@nixpulvis
nixpulvis / try_or.rs
Last active Sep 17, 2015
Try or Rust macro, for more generally treating Results as values.
View try_or.rs
macro_rules! try_or {
($expr:expr => $handler:expr) => (match $expr {
::std::result::Result::Ok(v) => v,
::std::result::Result::Err(e) => {
warn!("{}", e);
$handler
}
})
}
@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
You can’t perform that action at this time.