Skip to content

Instantly share code, notes, and snippets.

def hanoi(n, a='A', b='B', c='C'):
"""
move n discs from a to c using b as middle
"""
if n == 0:
return
hanoi(n-1, a, c, b)
print a, '->', c
hanoi(n-1, b, a, c)
newpath
270 360 moveto
0 72 rlineto
72 0 rlineto
0 -72 rlineto
closepath
fill
showpage
# graphics.py
"""Simple object oriented graphics library
The library is designed to make it very easy for novice programmers to
experiment with computer graphics in an object oriented fashion. It is
written by John Zelle for use with the book "Python Programming: An
Introduction to Computer Science" (Franklin, Beedle & Associates).
LICENSE: This is open-source software released under the terms of the
GPL (http://www.gnu.org/licenses/gpl.html).
from graphics import *
def main():
win = GraphWin("My Circle", 100, 100)
c = Circle(Point(50,50), 10)
c.draw(win)
win.getMouse() # Pause to view result
win.close() # Close window when done
main()
from graphics import *
def sierpinskiT(points,level,win):
colormap = ['blue','red','green','white','yellow','violet','orange']
p = Polygon(points)
p.setFill(colormap[level])
p.draw(win)
if level > 0:
sierpinskiT([points[0],getMid(points[0],points[1]),getMid(points[0],points[2])],level-1,win)
require 'socket'
host,port = ARGV
begin
STDOUT.print "Connecting..."
STDOUT.flush
s = TCPSocket.open(host,port)
STDOUT.puts "done"
require 'socket'
class ChatServer
def initialize(port)
@descriptors = []
@serverSocket = TCPServer.new('',port)
@serverSocket.setsockopt( Socket::SOL_SOCKET, Socket::SO_REUSEADDR , 1 )
puts "server started on port #{port}"
@descriptors << @serverSocket
#!/usr/bin/ruby
# coding: utf-8
# Video To Mp3 --> vtm.rb
#
# Amaç
# ---
#
# hedef klasördeki belirtilen uzantılara sahip tüm vidyoları mp3'e çevirme...
#
@ecylmz
ecylmz / mkpdf
Created February 11, 2011 20:51 — forked from roktas/jp
#!/bin/bash
# markdown ile yazılan dosyalardan pdf üret.
# Örnek: <betik> ~/examples.md
PATH=/var/lib/gems/1.8/bin:$PATH
[ $# -gt 0 ] || {
echo >&2 "Kullanım: $0 < markdown dosyası>"
echo >&2 "Örnek: $0 ~/examples.md"
#!/usr/bin/awk -f
# aşağıdaki biçimde gelen bir csv dosyadan lwat'a yüklenebilecek
# biçimde bir csv dosya oluştur:
#
# öğrenci no,ad soyad
#
# orijinal hali https://gist.github.com/3d690cbdfd6055b8a05b
BEGIN {