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/local/bin/ruby | |
require 'socket' | |
class File | |
def self.binary?(name) | |
myStat = stat(name) | |
return false unless myStat.file? | |
open(name) { |file| | |
blk = file.read(myStat.blksize) |
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 <iostream> | |
#include <vector> | |
#include <sstream> | |
#include <cctype> | |
using std::isalnum; | |
using std::isalpha; | |
using std::isdigit; | |
using std::isxdigit; | |
#define push(n) stack.push_back(n) |
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 'sinatra' | |
require 'gopherclient' | |
$types ={ | |
"0"=>"TXT", | |
"1"=>"DIR", | |
"2"=>"CSO", | |
"3"=>"ERR", | |
"4"=>"HEX", |
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 GopherClient | |
def parseurl(url) | |
opts=url.sub('gopher://','').split('/') # split the url by slashes | |
host=opts.shift # the first element will be our host | |
type=opts.shift # type is second | |
if !@types.has_key?(type) then # check to see if a type was provided | |
opts.unshift(type) # if not, then its part of the path, put it back | |
puts "No type given, assuming 1" # tell them the error of their ways | |
type="1" # and assume its a directory | |
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/perl | |
package GopherScript; | |
sub new | |
{ | |
my $class = shift; | |
my $self = { | |
hostname => shift, | |
port => shift, | |
mode => "dir", |
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/local/bin/ruby | |
require "open-uri" | |
id=ARGV[0] | |
if !id then | |
puts "No id given" | |
else | |
begin | |
puts open("http://gist.github.com/#{id}.txt").read | |
rescue |
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 fib(n) | |
if n == 0 || n == 1 | |
n | |
else | |
fib(n - 1) + fib(n - 2) | |
end | |
end | |
if $0 == __FILE__ | |
36.times do |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
public class fib { | |
public static int fib(int n) { | |
if (n <= 1) {return n;} | |
return fib(n-1) + fib(n-2); | |
} | |
public static void main(String[] args) { | |
for (int i = 0; i < 36; i++) | |
System.out.println("n = " + i + " => " + fib(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
(defun fib (n) | |
(if(or (= 0 n) (= 1 n)) n | |
(+ (fib (- n 1)) (fib (- n 2))))) | |
(defun start () | |
(loop for x from 0 to 35 collect | |
(format t "n = ~d => ~d~%" x (fib x)))) | |
(start) | |
(quit) |
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/mzscheme | |
#lang scheme | |
(define (fib n) | |
(if (or (= 0 n) (= 1 n)) n | |
(+ (fib (- n 1)) (fib (- n 2))))) | |
(let runfib ((i 0)) | |
(unless (= i 36) | |
(display (string-append "n = " (number->string i) " => " (number->string (fib i)) "\n")) | |
(runfib (+ i 1)))) |
OlderNewer