This file contains 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 QuestionType(models.Model): | |
""" | |
Типы тестов | |
""" | |
name = models.CharField(u'Название типа теста',max_length=50) | |
duration = models.PositiveIntegerField(u'продолжительность теста в минутах',blank=True,null=True) | |
class Question(models.Model): | |
""" |
This file contains 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 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"Название типа теста", |
This file contains 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
@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)) |
This file contains 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
-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,_,_,_,_,_,_,_,_,_,_,_} -> |
This file contains 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
(if (> (count elem) 2) (nth elem 2) nil) | |
(= a 0) | |
(if (> (count elem) 2) (nth elem 2) nil) |
This file contains 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
(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))}))) |
This file contains 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
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; |
This file contains 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
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()) |
This file contains 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 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): |
This file contains 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 -*- | |
from hashlib import sha1 | |
def dirty_fabric(checkfield, *fields): | |
class _dirty_field(object): | |
def __init__(self): | |
self._ckeckfield = checkfield | |
self._fields = fields | |
@property |
OlderNewer