Skip to content

Instantly share code, notes, and snippets.

# Ruby
[zuber@fish Projekty]$ ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
[zuber@fish Projekty]$ time ruby test.rb > /dev/null
real 0m33.294s
user 0m31.745s
sys 0m0.303s
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>Test dla bannerka</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$('#banner-width').change(function() {
def fib(n):
if n < 2:
return n
else:
return fib(n - 1) + fib(n - 2)
def fib2(n):
a, b = 0, 1
for x in range(n):
a, b = b, a + b
return a
def fib(n):
"""Działa, ale tylko dla n równego 1 lub 2. Poprawność częściowa ;-)"""
return n
class Die(object):
def __init__(self, n):
self.n = n
def roll(self):
"""Niestety ta funkcja jest jeszcze mało losowa. Dopracować!"""
return n
class Die(object):
def __init__(self, n):
self.n = n
def roll(self):
return random.randint(1, self.n)
from django.db import models
from django.contrib.auth.models import User
class Gallery(models.Model):
title = models.CharField( max_length=80)
owner = models.ForeignKey(User)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ['title', 'created_at']
# Create your views here.
from django.shortcuts import render_to_response
from gallery.models import Gallery
def gallery_list(request):
galleries = Gallery.objects.all()
return render_to_response('gallery/gallery_list.html', {'galleries': galleries})
from annoying.decorators import render_to
@render_to('template.html')
def foo(request):
bar = Bar.object.all()
return {'bar': bar}
# equals to
from django.views.generic.simple import direct_to_template