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
| . /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
| 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
| 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
| 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
| import pytest | |
| from websocket import create_connection | |
| @pytest.fixture(scope="module") | |
| def ws(request): | |
| ws = create_connection("ws://localhost:8080/bullet") | |
| def fin(): | |
| ws.close() |
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 checkAccess(target, flag): | |
| global user, groups | |
| if user == "root": | |
| return 1 | |
| try: | |
| return { | |
| 'owner': lambda u: 1 if target['owner'] == u else 0, | |
| 'group': lambda u: 1 if targer['group'] == u else 0, | |
| 'r': lambda u: 0, | |
| 'w': lambda u: 1, |
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.Monad | |
| import Data.Char | |
| -- Code examples for | |
| -- http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-8-of-13 | |
| newtype Parser a = P( String -> [(a, String)]) | |
| instance Monad Parser where | |
| return v = P (\inp -> [(v,inp)]) |
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
| ffmpeg -f alsa -ac 1 -ab 128k -i pulse -f x11grab -r 25 -s 1280x1024 -i :0.0+0,0 -vcodec libx264 -vpre lossless_ultrafast -threads 0 video.mkv # record hq desktop | |
| ffmpeg -i videokritbi.mp4 -sameq -acodec ac3 -ab 448k -ar 48000 output.avi # convert ti hq avi | |
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
| connection.openSignalingChannel = function(config) { | |
| var websocket = new WebSocket('ws://localhost:8008/voice/my_group'); | |
| websocket.channel = config.channel || this.channel; | |
| websocket.onopen = function () { | |
| websocket.push(JSON.stringify({ | |
| open: true, | |
| channel: websocket.channel | |
| })); | |
| if (config.callback) config.callback(websocket); | |
| }; |