This file contains hidden or 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
| # Rule 1. Carnivors and herbivors cannot live together. | |
| # For example, moving a lion to an enclosement with a zebra is not good, since the zebra will be eaten. | |
| zoo = Zoo() | |
| zoo.add_fenced_enclosure('Fenced area 1') | |
| zoo.add_fenced_enclosure('Fenced area 2') | |
| zoo.add_carnivore('lion', 'Fenced area 1') | |
| zoo.add_herbivore('zebra', 'Fenced area 2') | |
| assertThrows(zoo.move_animal('lion', 'Fenced area 2')) | |
| # Rule 2: Herbivors can live side-by-side. |
This file contains hidden or 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
| wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | |
| sudo sh -c 'echo "deb http://dl.google.com/linux/talkplugin/deb/ stable main" >> /etc/apt/sources.list.d/google.list' | |
| sudo apt-get update | |
| sudo apt-get install google-talkplugin |
This file contains hidden or 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
| javascript:{var txt = prompt('Minddumpa vad?'); alert(txt); } |
This file contains hidden or 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
| # coding: utf-8 | |
| import unittest | |
| # Unit tests for kata 'domevent' | |
| ''' Synchronous domain events in pure Python. | |
| #- triggering an event | |
| #- registering a callback | |
| #- triggering an event with 1 handler | |
| #- triggering an event with 2 handlers |
This file contains hidden or 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
| from buz import Buz, Inbox | |
| buz = Buz() | |
| # Sending a message asynchronously is ridiculously simple | |
| def long_computation(self): | |
| # looong slow algorithm (possibly involving polling I/O ports!) | |
| buz.publish(SomeMessage(..)) | |
| # Remember the hell we go through to do things in parallell |
This file contains hidden or 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
| import Image | |
| block = 7 | |
| img = Image.open('cutup.png') | |
| w, h = img.size | |
| print 'Image (w,h)=(%d,%d)' % (w,h) | |
| ws, hs = w/float(block), h/float(block) | |
| print 'Sub image (w,h)=(%d,%d)' % (ws, hs) |
This file contains hidden or 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
| <h1>jQuery demo</h1> | |
| <div id="theDiv"> | |
| Detta är en liten text. | |
| </div> | |
| <input id="theButton" type="button" value="Klicka mig!" /> | |
| <script type="text/javascript"> | |
| $(document).ready(function () { |
This file contains hidden or 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 MachineRunner(object): | |
| """Simple quantuum programming inspired finite state machine runner""" | |
| def add_machine(self, machine): | |
| self.signal_queue = Queue.Queue() # good for concurrent/threade op! | |
| self.machines.append(machine) | |
| def tick(self): | |
| while self.signal_queue.has_items(): | |
| sig = self.signal_queue.pop() |
This file contains hidden or 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
| import Queue | |
| import logging | |
| logging.basicConfig( | |
| format='%(funcName)s: %(message)s', | |
| level=logging.DEBUG | |
| ) | |
| class MachineRunner(object): | |
| def __init__(self): |
This file contains hidden or 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/env python | |
| import pygtk | |
| pygtk.require('2.0') | |
| import gtk | |
| import gobject | |
| BOOKING_MINUTES = 60 | |