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
(ns org.gadek.fun.bottles) | |
(defn bottle-cnt [stock] | |
(str (if (zero? stock) "No more" stock) | |
" bottle" (when (not (= 1 stock)) "s") | |
" of beer")) | |
(defn verses [& [stock prev]] | |
(lazy-seq (let [stock (or stock 0) ; start from 0 | |
prev (or prev (bottle-cnt 99)) ; even earlier -- 99 bottles |
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
// Ta tabela jest rozumiana przez JS -- wszystkie zmiany wprowadzać tutaj. | |
// | from | to | employees | seta | premia | kanał | prezencja | prefix | agregacja | | |
// |---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------| | |
var flds = [ dateFromField , dateToField, includeWorkersCb, setaType , forPremiaCb , accChannel , presence , prefix , agreg ]; | |
var r2fl ={//|---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------| | |
'R0' : " | | x | | | | | | ", | |
'R1a' : " x | x | x | | | x | x | |
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
parse_ini(Filename) -> | |
Str = string:tokens(os:cmd(["tar JxOf ", Filename, " settings.conf"]), "\n"), | |
parse_ini(Str, default, []). | |
parse_ini([], _Group, Res) -> Res; | |
parse_ini([Head|Tail], Group, Res) -> | |
[F|R] = Str = string:strip(Head), | |
case F of | |
$# -> parse_ini(Tail, Group, Res); | |
$[ -> parse_ini(Tail, string:strip(R, both, $]), Res); | |
_ -> [K|V] = string:tokens(Str, "="), |
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
# sauce of original Makefile magic: | |
# http://passingcuriosity.com/2008/literate-haskell-with-markdown-syntax-hightlighting/ | |
# modified by kgadek | |
# Ok, so I found Markdown+Bird style to be nice BUT editors have problems with Haskell code (indenting & stuff) when | |
# each line starts with ">". | |
# On the other hand LaTeX style is ok but LaTeX is often too powerful - distracts me all the time from actual code. | |
# But don't worry, I'm (nearly) an Engineer. Solution: | |
# Write Markdown style, enclose code with \begin{code}..\end{code} block and use small sed script to convert it to Markdown+Bird. |
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
package funsets | |
import org.scalatest.FunSuite | |
import org.junit.runner.RunWith | |
import org.scalatest.junit.JUnitRunner | |
/** | |
* This class is a test suite for the methods in object FunSets. To run | |
* the test suite, you can either: |
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 Control.Monad | |
data StackCalc a = StackCalc { runStackCalc :: [Int] -> ([Int], a) } | |
instance Monad StackCalc where | |
return x = StackCalc aux | |
where aux stack = (stack, x) | |
f >>= e = StackCalc aux | |
where aux stack = let (newstack, newval) = runStackCalc f stack |
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 Text.ParserCombinators.Parsec hiding (spaces) | |
import System.Environment | |
import Data.List (foldl') | |
import qualified Data.Map.Strict as M | |
main = interact getWords | |
getWords input = | |
case parse parseWords "words parser" input of |
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 python3.2 | |
import re | |
from operator import itemgetter | |
word2num = {} | |
num2word = {} | |
with open('potop.txt', mode='r', encoding='utf-8') as potop: | |
for line in potop: |
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
## Task: get 20 most common words in given text | |
## Input: http://home.agh.edu.pl/~dorosz/pjn/lab-01/potop.txt | |
## take a note this is in ISO-8859-2/CRLF. I converted it to UTF-8/LF: | |
## $ iconv -f ISO-8859-2 -t UTF-8 potop.txt > potop.tmp | |
## $ tr -d '\r' < potop.tmp > potop.txt | |
## Haskell: https://gist.github.com/kgadek/5213089 | |
## uses Parsec |
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
extend amber.DriverMsg { | |
// DriverMsg.type = DriverMsg.MsgType.PING / DriverMsg.MsgType.PONG | |
optional KeepaliveMsg keepaliveMsg = 10; | |
} | |
message Keepalive { | |
optional uint32 time = 1; // epoch! czas wysłania | |
} |
OlderNewer