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.Monad.Trans.Class (lift) | |
| import Control.Monad.Trans.Resource | |
| import System.IO | |
| main = runResourceT $ do | |
| (releaseO, output) <- allocate (openFile "output.txt" WriteMode) hClose | |
| lift $ hPutStrLn output "hallo!" | |
| release releaseO | |
| (releaseI, input) <- allocate (openFile "output.txt" ReadMode) hClose | |
| release releaseI |
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
| var getCss = function(el) { | |
| var style = window.getComputedStyle(el); | |
| return Object.keys(style).reduce(function(acc, k) { | |
| var name = style[k], | |
| value = style.getPropertyValue(name); | |
| if (value !== null) { | |
| acc[name] = value; | |
| } | |
| return acc; | |
| }, {}); |
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
| # Debugging metaclass | |
| # Put this in your class definition. | |
| def __metaclass__(name, bases, attrs): | |
| from functools import wraps | |
| try: | |
| import ipdb as pdb | |
| except ImportError: | |
| import pdb | |
| def debug_wrapper(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
| /** | |
| * Adapted from http://github.com/JetBrains/intellij-community | |
| * xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.flex | |
| */ | |
| package com.haskforce.yesod.shakespeare.hamlet.highlighting; | |
| import java.util.regex.Matcher; | |
| import java.util.regex.Pattern; | |
| import com.intellij.lexer.FlexLexer; | |
| import com.intellij.psi.tree.IElementType; |
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 FlexibleInstances, FunctionalDependencies, MultiParamTypeClasses #-} | |
| import Control.Monad | |
| import Control.Monad.Loops | |
| import Control.Monad.State | |
| import Data.Char | |
| class Iterator a b r | a -> b r where | |
| next :: (Monad m) => b -> StateT a m (Maybe r) |
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 ast | |
| def parse_version(source, name='__version__'): | |
| for exp in ast.parse(source).body: | |
| if isinstance(exp, ast.Assign) and name in (t.id for t in exp.targets): | |
| if len(exp.targets) != 1: | |
| raise ValueError('Cannot parse assignment unpacking.') | |
| if isinstance(exp.value, ast.Str): | |
| return exp.value.s |
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 Data.Text (Text) | |
| import Text.Blaze (ToMarkup) | |
| import Yesod | |
| import Yesod.Form.Bootstrap3 (BootstrapFormLayout(..), renderBootstrap3, bfs) | |
| bootstrapCheckBoxField :: (ToMarkup a, RenderMessage (HandlerSite m) FormMessage, Monad m) => a -> Field m Bool | |
| bootstrapCheckBoxField label = checkBoxField | |
| { fieldView = \theId name attrs val _ -> [whamlet|\ | |
| $newline never |
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 Prelude | |
| import Control.Monad.Logger (LoggingT, runStdoutLoggingT) | |
| import Control.Monad.Trans.Resource (ResourceT, runResourceT) | |
| import qualified Database.Persist | |
| import Database.Persist.Sql (SqlPersistT, runSqlPool) | |
| import qualified Settings | |
| import Yesod.Default.Config (DefaultEnv(Development), withYamlEnvironment) | |
| runDBDev :: SqlPersistT (LoggingT (ResourceT IO)) a -> IO a | |
| runDBDev m = do |
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
| -- This file should go either in your current working directory or your cabal data-dir. | |
| -- You can also reference it directly via: hlint --hint=path/to/HLint.hs | |
| -- http://community.haskell.org/~ndm/darcs/hlint/hlint.htm#customization | |
| error = fromJust ==> error | |
| error = undefined ==> error | |
| error = error ==> error |
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
| main = putStrLn "Hello world!" |