Based on hexlet.io react.js course's final task https://ru.hexlet.io/lessons/one_way_data_flow/theory_unit
This file contains hidden or 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.contrib.auth.models import User | |
| User._meta.get_field('username').max_length = 255 | |
| User.add_to_class('version', models.IntegerField(default=0)) | |
| User.add_to_class('pm_shard', models.IntegerField(blank=True, null=True)) | |
| User.add_to_class('is_board_agent', models.BooleanField(u'Агент доски объявлений', default=False)) | |
| User.add_to_class('coins_version', models.IntegerField(default=0)) | |
| User.add_to_class('banners_disabled', models.BooleanField(u'Выключен показ баннеров', default=False)) | |
| User.add_to_class('board_filters_subscriptions', models.IntegerField(u'Количество подписок на фильтры', default=0)) | |
| User.add_to_class('notify_messages', models.BooleanField(u'Уведомлять о новых сообщениях', default=True, | |
| help_text=u'Присылать письма при появлении новых личных сообщений, вопросов к объявлениям и ответов')) |
This file contains hidden or 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 Generator(object): | |
| def __init__(self, array): | |
| self.array = array | |
| self.index = 0 | |
| def __getitem__(self, item): | |
| if isinstance(item, slice): | |
| start = item.start if item.start else 0 | |
| self.index = (self.index + start) % len(self.array) | |
| return [self[0] for i in range(item.stop - start)] |
This file contains hidden or 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
| package main | |
| // Reverse ssh port forwarder | |
| // http://stackoverflow.com/questions/21417223/simple-ssh-port-forward-in-golang | |
| // https://godoc.org/code.google.com/p/go.crypto/ssh#example-Client-Listen | |
| import ( | |
| "code.google.com/p/go.crypto/ssh" | |
| "io" | |
| "log" |
This file contains hidden or 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
| . /etc/profile | |
| HISTSIZE=100 | |
| SAVEHIST=100 | |
| HISTFILE=~/.zsh_history | |
| setopt append_history | |
| setopt inc_append_history | |
| setopt extended_history | |
| setopt hist_find_no_dups | |
| setopt hist_ignore_all_dups | |
| setopt hist_reduce_blanks |
This file contains hidden or 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 Control.Applicative | |
| import Data.List | |
| import Test.HUnit | |
| -- based on http://www.haskellforall.com/2012/01/haskell-for-mainstream-programmers_28.html | |
| -- cabal instll HUnit | |
| -- rm -f *.o && rm -f Lens && rm -f *.tix && ghc -fhpc Lens.hs && ./Lens && hpc markup Lens | |
| -- view coverage in Main.hs.html | |
| -- Point data type | |
| data Point = Point { x :: Double, y :: Double } |
This file contains hidden or 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 index(request): | |
| @cached_as(News.objects.all()) #Что тут написать что бы так же работала инвалидация для Tag ? | |
| def _index(): | |
| c = {'news':News.objects.all(), | |
| 'tags':Tag.objects.all()} | |
| return render("index.html", c) | |
| return _index() |
This file contains hidden or 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
| # Есть структура данных описывающая пользователей | |
| # В socket будет попадать открытый обработчик WebSockerHandler | |
| user_list = [{'socket': tornado.websocket.WebSocketHandler(), | |
| 'groups': ['all', 'some group']}, | |
| {'socket': tornado.websocket.WebSocketHandler(), | |
| 'groups': ['other group']}] | |
| #Функция отправки сообщения пользователям | |
| def send_message(message): |
This file contains hidden or 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
| (item 10 nil | |
| (item 20 nil | |
| (item 30 (item 25 nil) | |
| (item 35 nil)))) | |
| (+ 1 2) ;; 1 + 2 | |
| (def my-fun | |
| (fn [a b c] | |
| (* (+ a b) |
This file contains hidden or 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
| #include <stdio.h> | |
| void add(unsigned long long *dst, unsigned long long *src){ | |
| asm ("movq %0, %%rbx\n" | |
| /*"addq $8, %%rbx\n"*/ | |
| "movq (%%rbx), %%rax\n" | |
| "addq (%1), %%rax\n" | |
| "mov %%rax, (%%rbx)\n" | |
| /*"adcq $0, %%rax\n"*/ |