Anyone knows of a Haskell package that can render NominalDiffTime
(or a similar type) as human readable time duration?
Some examples of what I mean:
f :: NominalDiffTime -> String
f 1 = "1 second"
f 10 = "10 seconds"
I like multitasking quite a lot, jumping in and out of games and applications. Even with an SSD I don't like to wait for software to start up, especially games. Many software are written well enough that when they are in the background, e.g. minimized they use less resources such as CPU. But some aren't and that drives me a bit crazy.
"Why do you have to constantly eat 7%/20%/80% of my CPU while you are doing nothing in the background, mister?"
I've written a proof of concept for Linux, which works quite as intended:
Usage:
#include <windows.h> | |
#include <stdio.h> | |
typedef LONG (NTAPI *NtSuspendProcess)(IN HANDLE ProcessHandle); | |
void suspend(DWORD processId) | |
{ | |
HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId); | |
NtSuspendProcess pfnNtSuspendProcess = (NtSuspendProcess)GetProcAddress( |
#!/usr/bin/env zsh | |
set -e | |
term="$1" | |
echo $term | |
loop=1 | |
asleep=.95 | |
awake="`echo "$loop - $asleep" | bc`" | |
echo "asleep: $asleep, awake: $awake" | |
trap cleanup INT |
let x = readFile "./test/IOScenario.hs" >>= lines .> groupByIndentation .> | |
filter (concat .> words .> (uncons .> maybe False (fst .> ("I" `isSuffixOf`)) | |
`andf` ((!!1) .> (/= "::")))) .> map (unlines .> break (== '=') .> fst .> | |
(<> "= undefined") .> parseDecs .> fmap (map ((,,) <$> f <*> ppr <*> id))) .> | |
map fromRight .> concat .> map ((\(a,b,c) -> do print a; print b; print c; | |
putStrLn "\n")) .> sequence_; f (FunD n [(Clause cs _ _)]) = (show n, map | |
(let asd = \case VarP a -> show a; ParensP a -> asd a; ConP n [VarP b] | n == | |
mkName "Inj" -> show b; _ -> "!!!!!" in asd) cs); f (ValD _ _ _) = ("!!!!", []) | |
in x |
var C_TYPE = 'Type', | |
C_TITLE = 'Title', | |
C_ID = 'ID', | |
C_URL = 'URL', | |
C_MIME_TYPE = 'file type', | |
C_ELEMENTS = 'elements in document'; | |
var HEADERS = [C_TYPE, C_TITLE, C_ID, C_URL, C_MIME_TYPE, C_ELEMENTS]; | |
function onOpen(){ |
addTwoNumbers a b = add a b | |
add = (+) | |
tests = do | |
let addTwoNumbers = assemble defs "addTwoNumbers" | |
addTwoNumbers 3 4 `shouldBe` 7 | |
let addTwoNumbers = assemble defs{add=(*)} "addTwoNumbers" | |
addTwoNumbers 3 4 `shouldBe` 12 |
<interactive>:121:67: error: | |
• No instance for (Typeable int) | |
arising from a use of ‘fromDynamic’ | |
• In the first argument of ‘(.>)’, namely | |
‘(fromDynamic :: Dynamic -> Maybe ((Int, int), Int -> Int -> Int))’ | |
In the expression: | |
((fromDynamic :: Dynamic -> Maybe ((Int, int), Int -> Int -> Int)) | |
.> fmap (\ ((a, b), f) -> f a b)) | |
In the second argument of ‘map’, namely | |
‘[((fromDynamic :: |
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages. | |
# ghc-pkg-clean -f cabal/dev/packages*.conf also works. | |
function ghc-pkg-clean() { | |
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'` | |
do | |
echo unregistering $p; ghc-pkg $* unregister $p | |
done | |
} | |
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place. |
// ==UserScript== | |
// @name Feedly fullscreen | |
// @namespace https://github.com/Wizek | |
// @version 0.1 | |
// @description Allows Youtube videos to be fullscreen in Feedly (and possibly other embedded media too, not just Youtube) | |
// @author Wizek | |
// @match https://feedly.com/* | |
// @grant none | |
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js | |
// @noframe |