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 ThriftConnection(object): | |
| def __init__(self, service, host, port): | |
| socket = TSocket.TSocket(host, port) | |
| self.transport = TTransport.TFramedTransport(socket) | |
| protocol = TBinaryProtocolAccelerated(self.transport) | |
| self.client = service.Client(protocol) | |
| self.transport.open() | |
| self.open_time = time.time() | |
| self.access_time = self.open_time | |
| self.str = "%s#%d(%s:%d/%s)" % (self.__class__.__name__, id(self), host, port, service.__name__.rsplit(".", 1)[-1]) |
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
| #!/usr/bin/env runghc | |
| import Control.Monad | |
| import Data.Function | |
| import Data.Functor | |
| import Data.List | |
| import System.Directory | |
| import System.FilePath | |
| data ELPA = ELPA FilePath |
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
| #!/usr/bin/env runghc | |
| import qualified Codec.Binary.Base32 as Base32 | |
| import Codec.Utils (i2osp, fromTwosComp) | |
| import qualified Control.Arrow as Arrow | |
| import Data.Bits | |
| import Data.Char | |
| import Data.Functor | |
| import Data.HMAC | |
| import Data.List.Split |
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
| bi :: (a -> b) -> (a -> c) -> a -> (b, c) | |
| bi f g (x) = (f x, g x) | |
| bi2 :: (a -> b -> c) -> (a -> b -> d) -> (a, b) -> (c, d) | |
| bi2 f g (x, y) = (f x y, g x y) | |
| tri :: (a -> b) -> (a -> c) -> (a -> d) -> a -> (b, c, d) | |
| tri f g h (x) = (f x, g x, h x) | |
| tri2 :: (a -> b -> c) -> (a -> b -> d) -> (a -> b -> e) -> (a, b) -> (c, d, e) |
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 Control.Applicative | |
| import Control.Monad | |
| import System.Directory | |
| import System.FilePath | |
| import System.Exit | |
| import System.Process | |
| import Text.Printf | |
| type URL = 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
| [1] |> Stream.iterate(fn(x) -> x |> Enum.chunk_by(&+/1) |> Enum.flat_map(fn([x|_]=c) -> [x, Enum.count(c)] end) end) |> Enum.take(10) |
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
| natural-sort [ zero? ] partition dup length 2 < [ 2drop -1 ] [ 2 cut swapd 3append zip-index [ second even? ] partition [ keys 0 [ swap 10 * + ] reduce ] bi@ + ] if | |
| natural-sort [ zero? ] partition dup length 2 < [ 2drop -1 ] [ 2 cut surround zip-index [ second even? ] partition [ keys 0 [ swap 10 * + ] reduce ] bi@ + ] if |
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
| : >column-name ( n -- s ) "" [ over zero? ] [ [ 1 - 26 /mod 65 + ] dip swap prefix ] until nip ; |
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
| dup 1 tail zip [ [ second ] [ first ] bi - ] sort-with first |
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 socket | |
| import signal | |
| server = None | |
| def sigusr1_handler(signum, frame): | |
| server.close() | |
| signal.signal(signal.SIGUSR1, sigusr1_handler) |