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
bytesRange :: Wai.Request -> FileLength -> (Integer, Integer) | |
bytesRange r l = fromMaybe (0,l) $ | |
(\case | |
ByteRangeFrom f -> (f, l-f) | |
ByteRangeFromTo f t -> (f, t-f+1) | |
ByteRangeSuffix s -> (l-s,s) | |
) <$> (requestHeaderRange r >>= parseByteRanges >>= listToMaybe) |
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
data Transcode = Transcode | |
{ inputUrl :: ByteString | |
, ffmpegOpts :: [ByteString] | |
, format :: ByteString | |
} | |
getOutputName :: ByteString -> [ByteString] -> ByteString -> ByteString | |
getOutputName i opts f = | |
(C.pack . List.map toLower . C.unpack . hex $ hashStrings (i : opts)) <> "." <> | |
f |
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
{-# LANGUAGE OverloadedStrings #-} | |
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-} | |
-- {-# LANGUAGE TDNR #-} | |
module Main where | |
import Control.Concurrent.STM | |
import Control.Exception | |
import Control.Monad | |
import Crypto.Hash.MD5 as MD5 |
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
// which would you do? comment below | |
// distinct ifs | |
if n == 1 { | |
single() | |
} | |
if n > 1 { | |
multi() | |
} |
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 time, datetime, re | |
def parse_go(logger, line): | |
event = { | |
'msg_text': line, | |
'priority': 'low', | |
} | |
try: | |
date = datetime.datetime.strptime(line[:19], "%Y/%m/%d %H:%M:%S") | |
except ValueError: |
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
type Msg | |
= ApiAvailability Cast.ApiAvailability | |
| CastContext Cast.JsContext | |
| RequestSession | |
| UrlChange Navigation.Location | |
| Navigate String | |
| NavbarMsg Navbar.State | |
| LoadMedia | |
| ProposedMediaInput (Cast.Media -> String -> Cast.Media) String |
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 g: | |
def __init__(self): | |
self.s = "f" | |
def __call__(self, c=None): | |
if c is None: | |
self.s += "o" | |
return self | |
else: | |
return self.s+c | |
def f(c=None): |
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 g: | |
def __init__(self): | |
self.s = "f" | |
def __call__(self, c=None): | |
if c is None: | |
self.s += "o" | |
return self | |
else: | |
return self.s+c | |
def f(c=None): |
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
usage = chunk(redis_cli('hgetall', key+':'+date), 2) | |
usage = map(lambda x: x[:1]+(int(x[1]),)+x[2:], usage) | |
usage = sorted(usage, key=lambda x: x[1], reverse=True) |
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
module StaleUpdater exposing (..) | |
type alias StaleUpdater = | |
{ stale : Bool | |
, updating : Bool | |
} | |
new : StaleUpdater |