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 InstanceSigs #-} | |
import Control.Applicative | |
import Control.Monad | |
import Control.Monad.Trans.Writer | |
-- Here is a direct style pythagoras function | |
-- There are two noticeable things in the function body. | |
-- 1. Evaluation order of x * x vs y * y is unknown/implicit. | |
-- 2. We don't care what happens to the final value (implicit continuation). | |
pyth :: (Floating a) => a -> a -> 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
-- | simple generic implementation | |
simpleHttp :: (MonadThrow m, HttpNetwork m User) => Id -> m () | |
simpleHttp = error "do me..." | |
-- | Implemenation from well-typed article | |
simpleHttp | |
:: (MonadThrow m, Throws HTTPException, Throws DBException, HttpNetwork m User) | |
=> Id -> m () | |
simpleHttp = error "do me..." |
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
-- | example of monadic effectful code that can throw multiple errors | |
simpleHttp | |
:: forall m . (ThrowsMany m '[ HTTPException, DBException ], HttpNetwork m User) | |
=> Id -> m User | |
simpleHttp userId = do | |
user <- getHttp userId | |
case uId user of | |
x | x == userId -> pure user | |
| x == "Null" -> throwChecked DBException | |
| otherwise -> throwChecked HTTPException |
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 DefaultSignatures #-} | |
{-# LANGUAGE DeriveAnyClass #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Checked where | |
import Data.Kind (Type, Constraint) | |
import Control.Exception.Safe | |
{- | |
This is an extended take and exploration on implementing Checked exemptions in haskell |
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
timestamp :: String -> Q a -> Q a | |
timestamp name action = do | |
start <- runIO getCurrentTime | |
runIO $ putStrLn $ "Starting " <> name <> ": " <> show start | |
a <- action | |
end <- runIO getCurrentTime | |
runIO $ do | |
putStrLn $ "Ending " <> name <> ": " <> show end | |
putStrLn $ "Elapased " <> name <> ": " <> show (diffUTCTime end start) | |
pure 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
{"version":1,"resource":"file:///Users/allan/apps/30-seconds/src/components/FrontPage/index.tsx","entries":[{"id":"m0FV.tsx","timestamp":1649923532589},{"id":"XzZD.tsx","timestamp":1649924691362},{"id":"5ZaR.tsx","source":"undoRedo.source","timestamp":1649924725895},{"id":"mlTF.tsx","timestamp":1649924995849},{"id":"9t2x.tsx","timestamp":1649925163927},{"id":"NwOV.tsx","timestamp":1649925174270}]} |
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
<html> | |
<body> | |
<span id="output"></span> | |
</body> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<script src="main.js"></script> | |
</html> |
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
SET @oldsite='http://oldsite.com'; | |
SET @newsite='http://newsite.com'; | |
UPDATE wp_options SET option_value = replace(option_value, @oldsite, @newsite) WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET post_content = replace(post_content, @oldsite, @newsite); | |
UPDATE wp_links SET link_url = replace(link_url, @oldsite, @newsite); | |
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldsite, @newsite); | |
/* only uncomment next line if you want all your current posts to post to RSS again as new */ | |
#UPDATE wp_posts SET guid = replace(guid, @oldsite, @newsite); |
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
#!/usr/bin/env python | |
# | |
# A simple Python script to convert csv files to sqlite (with type guessing) | |
# | |
# @author: Rufus Pollock | |
# Placed in the Public Domain | |
# Bug fixes by Simon Heimlicher <[email protected]> marked by `shz:' | |
from __future__ import print_function |
NewerOlder