Skip to content

Instantly share code, notes, and snippets.

class QuestionType(models.Model):
"""
Типы тестов
"""
name = models.CharField(u'Название типа теста',max_length=50)
duration = models.PositiveIntegerField(u'продолжительность теста в минутах',blank=True,null=True)
class Question(models.Model):
"""
from django.core.management.base import BaseCommand, CommandError
from optparse import make_option
from testing.models import QuestionType, Question, Answer
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option("-n", "--name",
dest="typename",
help=u"Название типа теста",
@ir4y
ir4y / patterns.py
Last active December 15, 2015 07:59
@patterns
def factorial():
with 0: 1
with n:
if n is int: n * factorial(n-1)
if n is not int: raise ValueError("Int needed")
with []: []
with [x] + xs: [factorial(x)] + factorial(xs)
with {'n': n, 'f': f}: f(factorial(n))
-module(find).
-export([find/2,walker/1]).
find(Re_name,Path) ->
io:format(file:read_file_info(Path)).
walker({dir_item,FileInfo,Path}) ->
case FileInfo of
{file_info,_,directory,_,_,_,_,_,_,_,_,_,_,_} ->
@ir4y
ir4y / test.clj
Last active December 16, 2015 08:19
(if (> (count elem) 2) (nth elem 2) nil)
(= a 0)
(if (> (count elem) 2) (nth elem 2) nil)
(ns schema
(:use clojure.test))
(defn apply-schema [schema data]
(if (vector? data)
(vec (map #(apply-schema (first schema) %) data))
(reduce merge (map (fn [item] (if (keyword? item)
{item (data item)}
(let [[[k v]] (vec item)]
{k (apply-schema v (data k))})))
public class Lagrange {
interface LagrangeFun {
double computate(double x);
}
public static LagrangeFun interpolate(final double[] x, final double[] y,final int n){
return new LagrangeFun() {
@Override
public double computate(double argx) {
double c, s=0;
def resouce_autodiscover():
from django.conf import settings
from django.utils.importlib import import_module
v1_api = Api(api_name='v1')
for app in settings.INSTALLED_APPS:
try:
resorce_api = import_module('%s.api' % app)
for resource_klass_name in resorce_api.__all__:
resource_klass = getattr(resorce_api, resource_klass_name)
v1_api.register(resource_klass())
class Transaction(models.Model):
owner = models.ForeignKey('auth.User')
datetime = models.DateTimeField(auto_now_add=True)
amount = models.PositiveIntegerField()
approved = models.BooleanField(default=False)
result = models.PositiveIntegerField(blank=True, null=True)
error = models.TextField(blank=True, null=True)
error_code = models.PositiveIntegerField(blank=True, null=True)
def operation_result(self):
# -*- coding: utf-8 -*-
from hashlib import sha1
def dirty_fabric(checkfield, *fields):
class _dirty_field(object):
def __init__(self):
self._ckeckfield = checkfield
self._fields = fields
@property