Skip to content

Instantly share code, notes, and snippets.

View DeTeam's full-sized avatar
🍪
le cookie

Timur Amirov DeTeam

🍪
le cookie
View GitHub Profile
@DeTeam
DeTeam / codeship.sh
Created December 30, 2014 19:13
Codeship Haskell setup commands
# Codeship + Haskell (cabal)
cabal update
cabal install cabal-install
export PATH=$HOME/.cabal/bin:$PATH
cabal sandbox init
cabal install --only-dependencies --enable-tests
cabal configure --enable-tests
cabal build
@DeTeam
DeTeam / core-async-thread.clj
Last active June 27, 2017 14:40
Example of killing a thread from core async pool. After thread is dead — new one will be created.
(ns deteam.core-async-sandbox
(:require [clojure.core.async :as async]
[clojure.tools.logging :as log]))
(def tmp-chan (async/chan 5))
(def waiting-time-ms 500)
(defn -main []
(log/info "Started the program")
module Main where
import Control.Monad.State.Lazy
import Control.Applicative ((<$>), (<*>))
myInc = state (\n -> (n, n * n))
myState = (,) <$> myInc <*> myInc
main = print $ computeState
@DeTeam
DeTeam / ApiSettings.hs
Created January 15, 2013 10:59
Thinking about data-type for storing all API-related settings.
data ApiSettings = ApiSettings {
settingsAuth :: Maybe BasicAuth
}
// It JavaScript it's okay to do like that:
friend.gift = function(){
var deferred = $.Deferred();
somewhenInFuture(function(gift){
deferred.resolve(gift);
})
return deferred.promise();
}
import Control.Concurrent
import Control.Concurrent.Async
import System.Random
delayedOutput :: String -> IO ()
delayedOutput m = do
gen <- newStdGen
let (t, _) = randomR (1, 10) ge
-- delay in microseconds
threadDelay (t * 1000000)
import Control.Concurrent
import Control.Concurrent.Chan
import System.Random
delayedOutput :: String -> Chan String -> IO ()
delayedOutput m c = do
gen <- newStdGen
let (t, _) = randomR (1, 10) gen
-- delay in microseconds
module ConceptCode (
up,
down
) where
import Control.Monad
import Data.List
{-
@DeTeam
DeTeam / Main.hs
Created May 29, 2012 16:37
Concept Codes
import Control.Monad
import Data.List
-- !! TODO: обернуть всю эту красоту в модуль, мб отдельные типы данных добавить
{-
Супер классная штука для формирования списка списков %)
Да, ее надо запомнить
tmp = Tempfile.new("out")
tmp << "things"
tmp.close
puts File.read(tmp.path)