Skip to content

Instantly share code, notes, and snippets.

Steve Severance sseveran

Block or report user

Report or block sseveran

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sseveran
sseveran / ray_tune_reporter_hook.py
Created Jun 15, 2018
A Tensorflow hook for reporting state to ray-tune
View ray_tune_reporter_hook.py
import six
import tensorflow as tf
from tensorflow.python.framework import ops
from tensorflow.python.training import training_util
from tensorflow.python.training.session_run_hook import SessionRunArgs
class RayTuneReportingHook(tf.train.SessionRunHook):
def __init__(self, params, reporter):
self.reporter = reporter
View gist:3aa2d9afbbba8bb4883d
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Data.Array.Accelerate as A
import Data.Array.Accelerate.CUDA
import qualified Data.Array.Accelerate.Interpreter as I
import Data.Array.Accelerate.Pretty
import Data.Array.Unboxed
import qualified Data.List as L
import System.Random
View STM-talk
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Concurrent.STM
newtype Money = Money Int deriving (Show, Num, Ord, Eq)
data Account = Account{
aBalance :: Money,
aAccountId :: Int
}
@sseveran
sseveran / gist:3588176
Created Sep 1, 2012
Uncaught Exceptions
View gist:3588176
-- | when no catch frame handles an exception dump core and terminate the process
uncaughtExceptionHandler :: SomeException -> IO ()
{-# NOINLINE uncaughtExceptionHandler #-}
uncaughtExceptionHandler !e = do
syslog Error $ "Unhandled exception: " ++ show e
raiseSignal sigABRT
setDefaultUncaughtExceptionHandler :: IO ()
setDefaultUncaughtExceptionHandler =
setUncaughtExceptionHandler uncaughtExceptionHandler
@sseveran
sseveran / gist:3517817
Created Aug 29, 2012
Exception Scoping 5
View gist:3517817
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
import Control.DeepSeq
import Control.DeepSeq.TH
import Control.Exception
import Data.Typeable
import Prelude hiding (catch)
@sseveran
sseveran / gist:3430096
Created Aug 22, 2012
Exception Scoping 4
View gist:3430096
data MyRecord = MyRecord{
mrField :: [Text]
}
(do
some operations...
return $ MyRecord $ fmap (decodeUtf8) listOfByteStrings)
`safeCatch`
myHandler
@sseveran
sseveran / gist:3430089
Created Aug 22, 2012
Exception Scoping 3
View gist:3430089
safeCatch :: (Exception e, NFData a) => IO a -> (e -> IO a) -> IO a
safeCatch func handler = catch eval handler where
eval = do
x <- func
rnf x `seq` return $! x
@sseveran
sseveran / gist:3430084
Created Aug 22, 2012
Exception Scoping 2
View gist:3430084
data MyRecord = MyRecord{
mrField :: [Text]
}
(do
some operations...
return $ MyRecord $ fmap (decodeUtf8) listOfByteStrings)
`catch`
myHandler
@sseveran
sseveran / gist:3430017
Created Aug 22, 2012
Exception Scoping 1
View gist:3430017
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Exception
import Prelude hiding (catch)
iThrowExceptions :: Int
iThrowExceptions = error "I am a slippery exception"
data Record = Record Int deriving (Show)
main :: IO ()
main = do
You can’t perform that action at this time.