Skip to content

Instantly share code, notes, and snippets.

View iokasimov's full-sized avatar
🗿

Murat Kasimov iokasimov

🗿
View GitHub Profile
var main = function(continets){
var counter = 0;
var agencies = [];
var on_complete = function(err, data){
agencies = agencies.concat(data);
counter++;
}
async.each(continents,
var path = require('path');
var async = require('async');
var config = require(path.join(process.cwd() + '/src/config'));
var processor = require(path.join(process.cwd() + '/src/processor'));
var continents = ['australia','north-america','europe'];
var p = new processor.Processor();
// asynchonously parsing each continent
var main = function(continets){
// asynchonously parsing each continent
var main = function (continets, on_complete) {
var counter = 0;
var agencies = [];
on_complete = function (err, data) {
agencies = agencies.concat(data);
counter++;
if (counter === continents.length) {
return agencies;
var path = require('path');
var async = require('async');
var config = require(path.join(process.cwd() + '/src/config'));
var processor = require(path.join(process.cwd() + '/src/processor'));
var continents = ['australia','north-america','europe'];
var p = new processor.Processor();
// asynchonously parsing each continent
var main = function (continets, on_complete) {

Explanation of working asynchronous API:

List of endpoints:

  • GET /detect
  • POST /detect
  • GET /detect/state
  • GET /detect/result

So, we have 4 methods: the first two are doing the same things - just starts detecting, the third is checking on state of detecting, the fourth outputs the result.

import System.Random
type Person = String
type Party = [(Person,Person)]
people = ["Sergey", "Eugeny", "Georgy", "Vsevolod", "Daniil", "Murat"]
rshift :: IO Int
rshift = randomRIO (1::Int, (length people) - 2)
module Line (Line(..), extract, left, right, allfocuses, neighbourhood, mean, onsides, makelist, st_makelist, smoothmean, smoothwith) where
import Data.Maybe
data Line a = Line [a] a [a] deriving (Eq, Show)
instance Functor Line where
fmap f (Line ls a rs) = Line (map f ls) (f a) (map f rs)
extract :: Line a -> a
@iokasimov
iokasimov / cps.hs
Last active February 24, 2017 17:34
import Data.Void
import Control.Monad.Trans.Cont
type Program = Cont Context Void
data Status = Failure | Success deriving Show
data Context = Read (String -> Context) | Write String Context | Exit Status
readline :: Cont Context String
readline = cont Read
import qualified Line
import Data.Maybe
newtype Grid a = Grid { grid :: Line.Line (Line.Line a) } deriving Show
instance Functor Grid where
fmap f = Grid . (fmap . fmap) f . grid
extract :: Grid a -> a
extract = Line.extract . Line.extract . grid
@iokasimov
iokasimov / wgc.hs
Last active February 26, 2017 10:35
Wolf, Goat and Cabbage
import Control.Lens
import Data.List
import Data.Either
import Control.Error.Util
data Being = Wolf | Goat | Cabbage deriving (Eq, Show)
data Direction = Leftward | Rightward
type Boat = Maybe Being
type Coast = [Being]
type River = (Coast, Coast)