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
--Есть 2 таблицы: | |
--users | |
--UID Name | |
--1 «Александр» | |
--2 «Семён» | |
--messages | |
--UID msg | |
--1 “A” | |
--1 “B” |
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 decimal import Decimal, ROUND_HALF_UP | |
import logging | |
logging.basicConfig(level=logging.DEBUG) | |
# Constants for rounding | |
TWO_DIGITS_ROUND = Decimal("0.01") | |
SIX_DIGITS_ROUND = Decimal("0.000001") | |
result_lst = [] |
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
--Задача: есть таблица | |
fish | |
name CHAR(20) | |
price INT(5) | |
date DATE | |
--В таблице есть данные: | |
forel 2012-01-01 10 | |
forel 2012-01-03 6 |
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
SELECT i.route_id, min(t.cost) m | |
FROM (SELECT DISTINCT route_id FROM tickets) AS i, tickets t | |
WHERE i.route_id = t.route_id AND | |
city_from='ABC' AND | |
city_to='ABC' AND | |
date_direct='2012-05-24' AND | |
date_back='2012-05-25' AND | |
expires > NOW() | |
GROUP BY t.route_id | |
ORDER BY m; |
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
import time | |
from wsgiref.util import setup_testing_defaults | |
from wsgiref.simple_server import make_server | |
def timeit(func): | |
def wrapper(*a, **k): | |
t1 = time.time() | |
it = iter(func(*a, **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
s = """ | |
73167176531330624919225119674426574742355349194934 | |
96983520312774506326239578318016984801869478851843 | |
85861560789112949495459501737958331952853208805511 | |
12540698747158523863050715693290963295227443043557 | |
66896648950445244523161731856403098711121722383113 | |
62229893423380308135336276614282806444486645238749 | |
30358907296290491560440772390713810515859307960866 | |
70172427121883998797908792274921901699720888093776 | |
65727333001053367881220235421809751254540594752243 |
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
(setq org-directory "~/org/") | |
(load-file "/home/gennad/.emacs.d/emacs-for-python/epy-init.el") | |
;; To require | |
;;(add-to-list 'load-path "~/.emacs.d/http") | |
;;(require 'http-post-curl) | |
;;(require 'http-twiddle) | |
;;(load-file "/home/gennad/.emacs.d/http-post-curl.el") |
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
# Set up the prompt | |
autoload -Uz promptinit | |
promptinit | |
prompt adam1 | |
setopt histignorealldups sharehistory | |
# Use emacs keybindings even if our EDITOR is set to vi | |
bindkey -e |
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
// function template | |
#include <iostream> | |
using namespace std; | |
template <class T> | |
T GetMax (T a, T b) { | |
T result; | |
result = (a>b)? a : b; | |
return (result); | |
} |
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
// Compile with g++ -o multithreading.o multithreading.cc -lpthread | |
#include <pthread.h> | |
#include <errno.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <unistd.h> | |
#include <string.h> |