Skip to content

Instantly share code, notes, and snippets.

@tstone
tstone / fizzbuzz lisp
Created October 29, 2009 07:24
Conceptual LISP FizzBuzz solution
(define (fizzbuzz start end) (
(define (print x) ( ..something.. ))
(cond
(= (mod start 15) 0) (print "fizzbuzz"))
(= (mod start 3) 0) (print "fizz"))
(= (mod start 5) 0) (print "buzz"))
((print start))
)
(cond
((< start end) ((fizzbuzz (+ 1 start) end)))
@tstone
tstone / fizzbuzz-python.py
Created October 29, 2009 07:25
Recursive Python FizzBuzz solution
def fizzbuzz (start, end):
if start % 15 == 0:
print 'fizzbuzz'
elif start % 3 == 0:
print 'fizz'
elif start % 5 == 0:
print 'buzz'
else:
print start
@tstone
tstone / fizzbuzz.rb
Created November 2, 2009 01:18
Recursive FizzBuzz Ruby
def fizzbuzz(start, ending)
if (start % 15 == 0)
puts 'Fizzbuzz'
elsif (start % 5 == 0)
puts 'Buzz'
elsif (start % 3 == 0)
puts 'Fizz'
else
puts start
end
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
CONFIG = 'C:\Mercurial\hgwebdir\hgweb.config'
application = hgwebdir(CONFIG)
@tstone
tstone / httpd.conf
Created November 3, 2009 17:47
Mercurial Apache Virtual Host
# ---- HTTPS -- Mercurial Virtual Host ----
<VirtualHost *:443>
ServerName hg.yourdomain.com:443
ServerAdmin webmaster@yourdomain.com
DocumentRoot "C:\Mercurial\repositories"
WSGIScriptAliasMatch ^(.*) C:\Mercurial\hgwebdir\hgwebdir.wsgi$1
<Directory "C:\Mercurial\hgwebdir">
// When the toolbar button is clicked...
$('#newNickButton').click(function() {
var newNick = getNewNickname();
setNewNickname(newNick);
}
function getNewNickname() {
// Build dialog markup
var win = $('<div><p>Enter your new nickname</p></div>');
// When the toolbar button is clicked...
$('#newNickButton').click(function() {
getAndSetNewNickname(null);
}
function getAndSetNewNickname(nick) {
if (typeof(nick) === 'undefined') {
showNickDialog(function(value){
getAndSetNewNickname(value);
})
#
# A python module to implement recursive search/copy of files
#
import datetime
import shutil
import os
import re
class DirSearch(object):
import os
import sys
from dirsearch import DirSearch
# Global variables
PREFIX = ''
#
# Print the basic help to the screen
from django.db import models
from django.shortcuts import _get_queryset
class ChildAwareModel(models.Model):
class Meta:
abstract = True
def get_child_model(self):
"""
Attempts to determine if an inherited model record exists.