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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
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 view_vote(request, aid = 0): | |
result = {'success': False} | |
cookie_set = False | |
try: | |
interview = Interview.objects.latest() | |
answer = Answer.objects.get(id = aid) | |
except: | |
result['message'] = 'Answer or interview not founded' | |
else: | |
if answer.interview.id != interview.id or interview.on == False: |
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 -*- | |
""" | |
Extremely fast Django test runner, based on the idea that your database schema | |
and fixtures are changed much more seldom that your code and tests. All you | |
need is to make sure that your "quickstart.sqlite" database file is always up | |
to date. | |
BEWARE: Don't run this test runner on production server. It assumes that you | |
use only one database configured as "default", and its db engine is SQLite. | |
Otherwise your tests can eat your data! |
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
# change postgresql template1 db encoding to utf8 (unicode) by dropping it and recreating from template0 | |
UPDATE pg_database SET datistemplate=false WHERE datname='template1'; | |
drop database template1; | |
create database template1 with template = template0 encoding = 'UTF8'; |
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
ko.mustacheTemplateEngine = function () { | |
this['getTemplateNode'] = function (template) { | |
var templateNode = document.getElementById(template); | |
if (templateNode == null) | |
throw new Error("Cannot find template with ID=" + template); | |
return templateNode; | |
} | |
this['renderTemplate'] = function (templateId, data, options) { |
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
#!/usr/bin/env python | |
#coding: utf-8 | |
from optparse import OptionParser | |
from datetime import date, datetime | |
from pwd import getpwnam | |
import unidecode | |
from libs.script_utils import get_email_logger | |
import getpass |
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 | |
def get_email_logger(addrs, subject, email_settings): | |
''' Returns logger that send email ''' | |
import logging | |
import logging.handlers | |
assert 'host' in email_settings, "email settings, host needed" |
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 | |
import enchant | |
LAT = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', | |
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] | |
a_list = [1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25] | |
m = len(LAT) | |
CODE = """ |
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 | |
LAT = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', | |
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] | |
CODE = """ | |
FUBSWRJUDSKLF NHBV DUH DQDORJRXV WR WKH KRXVH DQG FDU NHBV ZH FDUUB LQ RXU | |
GDLOB OLYHV DQG VHUYH D VLPLODU SXUSRVH | |
""" |
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
#!/usr/bin/env python | |
#coding: utf-8 | |
import os | |
import json | |
from optparse import OptionParser | |
INPUT_REQ = """ | |
Input filename. Requirements: | |
1) Wavefront format (.obj) | |
2) One object in one file |
OlderNewer