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
class Object | |
def metaclass | |
class << self; self; end | |
end | |
end | |
module CannedScopes | |
def self.included base | |
base.send :extend, ClassMethods | |
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
<VirtualHost *:80> | |
ServerName mohole.net | |
ServerAlias www.mohole.net | |
DocumentRoot /home/mohole/current/public | |
<Directory "/home/mohole/current/public/"> | |
Options FollowSymLinks | |
AllowOverride None | |
Order allow,deny | |
Allow from all |
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
rightTriangles = [ (a,b,c) | c <- [1..500], b <- [1..c], a <- [1..b], a^2 + b^2 == c^2] | |
main = print rightTriangles |
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
puts (1..500).inject([]) {|acc,a| | |
(1..a).inject(acc) {|acc,b| | |
(1..b).inject(acc) {|acc,c| | |
acc << [a, b, c] if (a**2) == (b**2) + (c**2) | |
acc | |
} | |
} | |
}.map {|triangle| triangle.inspect }.join(',') |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
bool rightTriangle(int a, int b, int c) { | |
return a*a == b*b + c*c; | |
} | |
void printTriangle(int a, int b, int c, bool printed) { | |
printf("%s[(%i),(%i),(%i)]", (printed ? "," : ""), a, b, c); |
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
module Enumerable | |
def sift! &block | |
ret, keep = partition {|i| | |
yield i | |
} | |
self.replace keep | |
ret | |
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
#!/bin/bash | |
iptables="iptables" | |
# network settings | |
iface_main="eth0" | |
iface_vhosts="eth0:0" | |
ip_main=`ifconfig $iface_main | grep "inet addr" | cut -d: -f2 | cut -d" " -f1` | |
ip_vhosts=`ifconfig $iface_vhosts | grep "inet addr" | cut -d: -f2 | cut -d" " -f1` | |
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
require 'rubygems' | |
require 'hpricot' | |
class Requester | |
def initialize | |
`touch cookies` | |
login | |
end | |
def login |
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
class Integer | |
def to_ord | |
self.to_s + ((10...20) === self ? 'th' : %w{th st nd rd th th th th th th}[int % 10]) | |
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
rightTriangles :: [(Int, Int, Int)] | |
rightTriangles = [ (a,b,c) | c <- [1..100], b <- [1..c], a <- [1..b], a*a + b*b == c*c] | |
main = print rightTriangles |