Skip to content

Instantly share code, notes, and snippets.

View alogic0's full-sized avatar

Oleg Tsybulskyi alogic0

  • Odessa, Ukraine
View GitHub Profile
@alogic0
alogic0 / parseExpr.hs
Last active October 12, 2016 02:38
FutureLearn Haskell 2016, Parsing Text, Expression parsers
import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Expr
import qualified Text.ParserCombinators.Parsec.Token as P
import Text.ParserCombinators.Parsec.Language
import Control.Monad (liftM)
lexer = P.makeTokenParser emptyDef
parens = P.parens lexer
natural = P.natural lexer
@alogic0
alogic0 / primeS.hs
Created October 30, 2016 06:54
primes numbers, effective algorithm
-- source: http://www.garrisonjensen.com/2015/05/13/haskell-programs-are-lies.html
import qualified Data.Set as PQ
primes :: [Integer]
primes = 2:sieve [3,5..]
where
sieve (x:xs) = x : sieve' xs (insertprime x xs PQ.empty)
sieve' (x:xs) table
@alogic0
alogic0 / echoserv.py
Last active November 19, 2016 18:38
tcp echo server on python
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('127.0.0.1', 1234))
s.listen(10)
while True:
conn, addr = s.accept()
while True:
data = conn.recv(1024)
if not data: break
conn.send(data)
@alogic0
alogic0 / HsSuccess.md
Last active December 1, 2016 10:33 — forked from sigrlami/ab.md
Haskell Success Stories
@alogic0
alogic0 / стихи.txt
Created December 6, 2016 19:00
стихи
когда пришёл, угомонился
себе тихонечко лежишь
тогда и счастье привалится
и станет радостнее жить
@alogic0
alogic0 / en2ru.hs
Last active December 9, 2016 04:27
Convert mistyped text from English keyboard to Russian
import Data.Maybe (maybe)
import Data.Char (toUpper)
import System.IO (hGetContents, stdin)
import Control.Monad (liftM, forM_)
ruKeysL = "ёйцукенгшщзхъфывапролджэячсмитьбю"
ruKeysU = map toUpper ruKeysL
ruKeysP = ".,"
enKeysL = "`qwertyuiop[]asdfghjkl;\'zxcvbnm,."
@alogic0
alogic0 / Newton_vs_Nye_rap.txt
Last active December 19, 2016 06:17
Sir Isaac Newton vs Bill Nye. Epic Rap Battles of History Season 3
https://youtu.be/8yis7GzlXNM
Newton:
Of all the scientific minds in history
they put Beaker in a bow tie
up against me?
I'm a master
I discovered gravity
I drop rhymes like
they are falling from an apple tree
you're no match for me
main = interactionOf(initial, step, event, draw)
astSize = 0.6
data World = World {
stars :: [(Point, Number)],
asts :: [(Point, Vector)],
ship :: (Point, Vector),
direction :: Number,
left :: Number,
@alogic0
alogic0 / Voinovich, Monumental Propaganda.txt
Last active October 31, 2017 02:50
Quotes from the book "Монументальная Пропаганда" by Владимир Войнович
1. Гл. 14
стыдно до слез
смотреть на людей, которые оплевывают то, что вчера превозносили. Когда
Сталин был жив, я не помню такого случая, чтобы кто-то сказал, что Сталин
ему чем-то не нравится. Все в один голос говорили: гений. Великий
полководец. Отец и учитель. Корифей всех наук. Неужели они все не верили в
то, что говорили? Неужели все врали? Не могу понять, когда же эти люди были
искренни, сейчас или тогда?
время фанатиков истекло. Их не любят не только какие-нибудь антисоветчики
@alogic0
alogic0 / dice.elm
Last active January 18, 2018 09:14
Elm, rolling a dice with 'rotation'
-- origin https://gist.github.com/h3h/ce339825f2ba8fe1e4d3bf2d1a3e60da
import Html exposing (..)
import Html.Attributes
import Html.Events exposing (..)
import Process exposing (..)
import Time exposing (..)
import Task exposing (..)
import List
import Random