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
readMore <- atomically $ do | |
closing <- readTVar $ acClosing state | |
if not closing then return False | |
else do | |
inflight <- readTVar $ acInFlight state | |
return $ inflight /= 0 |
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
saveVector :: String -> Vector a -> IO () | |
saveVector name vec = | |
withFile name WriteMode $ \h -> do | |
let (ptr, len) = U.unsafeToForeignPtr0 vec | |
withForeignPtr ptr $ \p -> hPutBuf h p (len * sizeOf (0 :: a)) | |
loadVector :: String -> IO Vector a | |
loadVector name = | |
withFile name ReadMode $ \h -> do | |
len <- liftM fromIntegral $ hFileSize h |
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
{-# LANGUAGE ScopedTypeVariables #-} | |
module VV where | |
import Control.Monad | |
import Foreign.ForeignPtr.Safe | |
import Foreign.Storable | |
import System.IO | |
import qualified Data.Vector.Storable as U | |
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 qualified Data.Vector as V | |
import qualified Data.Vector.Unboxed as U | |
type Coloring = U.Vector Word32 | |
type Links = V.Vector (U.Vector Int) | |
colors :: Coloring | |
links :: Links | |
allColors, deadColors :: U.Vector Color |
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
$ ls -l test.txt | |
-rw-rw-r-- 1 blaze blaze 69979380 Aug 26 12:08 test.txt | |
$ wc -l test.txt | |
8994700 test.txt | |
Strict Data.Bytestring + decodeUtf8 -- 5 секунд | |
Strict Data.Text.IO -- 7 секунд | |
Lazy Data.Bytestring + decodeUtf8 -- 10 секунд | |
Lazy Data.Text.IO -- 12 секунд |
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 XMonad | |
import XMonad.Config.Gnome | |
import XMonad.Util.EZConfig | |
import XMonad.Hooks.ManageHelpers (isFullscreen,doFullFloat) | |
import qualified XMonad.StackSet as W | |
myWorkspaces = ["1","2","3","4","5","6","7","8","9"] | |
main = xmonad $ gnomeConfig |
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
{-# LANGUAGE ScopedTypeVariables #-} | |
module Main where | |
import Control.Exception | |
import System.Exit | |
main :: IO () | |
main = do | |
r <- catch (do | |
let [r, _] = ['a'] |
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
0 : 0 0 0 0 0 0 0 0 0 | |
1 : 1 0 0 0 0 0 0 0 0 | |
12 : 12 0 0 0 0 0 0 0 0 | |
123 : 81 23 0 0 0 0 0 0 0 | |
1234 : 92 34 0 0 0 0 0 0 0 | |
12345 : c1 45 23 0 0 0 0 0 0 | |
123456 : d2 56 34 0 0 0 0 0 0 | |
1234567 : e1 23 67 45 0 0 0 0 0 | |
12345678 : f0 78 56 34 12 0 0 0 0 | |
123456789 : f1 89 67 45 23 0 0 0 0 |
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
type Field = array<bool> | |
let rec printField xsize (field : Field) = | |
let printLine i = Array.sub field (i * xsize) xsize |> Array.map (fun v -> if v then 'X' else '.') | |
[for n in 0 .. field.Length / xsize - 1 -> System.String(printLine n)] | |
let genField size (g : System.Random) = Array.init size (fun _ -> g.Next(100) < 20) | |
let hasMine xsize (field : Field) (x, y) = field.[y * xsize + 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
#define CHECK(x) \ | |
do { \ | |
NTSTATUS __l_status = (x); \ | |
if (! BCRYPT_SUCCESS(__l_status)) { \ | |
printf("ERROR: `%s` returned %x\n", #x, __l_status); \ | |
return 1; \ | |
} \ | |
} while (0) | |
UCHAR masterSecret[128]; |