Skip to content

Instantly share code, notes, and snippets.

@chrisdone
chrisdone / race-condition.txt
Created May 28, 2019 10:27
nodejs race condition
chris@precision:~$ docker run --rm -it --network host --name graphqcurl -v`pwd`:`pwd` -w`pwd`/server/ hasura/graphql-engine-console-builder:20190515 sh
# npm install -g graphqurl
npm ERR! write after end
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-05-28T10_27_09_410Z-debug.log
#
chris@precision:~$ docker run --rm -it --network host --name graphqcurl -v`p`pwd` -w`pwd`/server/ hasura/graphql-engine-console-builder:20190515 sh
# npm install -g graphqurl
npm ERR! write after end
@chrisdone
chrisdone / timings.txt
Created May 23, 2019 17:41
Building things in prana
chris@precision:~/Work/chrisdone/prana$ time sh prana-ghc/regenerate.sh
+ stack build --test --no-run-tests
prana-interpreter-0: Test running disabled by --no-run-tests flag.
Log files have been written to: /home/chris/Work/chrisdone/prana/.stack-work/logs/
+ rm -r /home/chris/Work/chrisdone/prana/prana-dir/
+ mkdir -p /home/chris/Work/chrisdone/prana/prana-dir/packages/
+ cd /home/chris/Work/chrisdone/prana/ghc-8.4/libraries/ghc-prim/
+ PRANA_DIR=/home/chris/Work/chrisdone/prana/prana-dir/ PRANA_MODE=INSTALL time -p -- ./Setup build --ghc-options=-O0
Preprocessing library for ghc-prim-0.5.2.0..
@chrisdone
chrisdone / ArrayTest.hs
Created May 22, 2019 17:15
Prana primops demo
{-# LANGUAGE MagicHash, UnboxedTuples #-}
-- | Test some of the ops for Array# and MutableArray#.
module ArrayTest where
import GHC.Exts
import GHC.Types (IO(..))
it :: IO (Char, Int, Char)
@chrisdone
chrisdone / errors.txt
Created May 22, 2019 13:00
Hasura console errors
chris@precision:~/Work/hasura/graphql-engine$ docker run --rm -it --network host --name hasura-console -v`pwd`:`pwd` -w`pwd`/console hasura/graphql-engine-console-builder:20190515 sh
# npm install
npm install
npm WARN lifecycle graphql-engine-console@0.1.0~postinstall: cannot run in wd graphql-engine-console@0.1.0 webpack --display-error-details --config webpack/prod.config.js (wd=/home/chris/Work/hasura/graphql-engine/console)
npm WARN codemirror-graphql@0.6.12 requires a peer of graphql@^0.10.0 || ^0.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN extract-text-webpack-plugin@3.0.2 requires a peer of webpack@^3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN less-loader@2.2.3 requires a peer of less@^2.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN graphiql@0.11.11 requires a peer of graphql@^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 but none is installed. You must install peer de
@chrisdone
chrisdone / 1-test-suite-requirements.txt
Last active May 22, 2019 12:58
Hasura python test suite
chris@precision:~/Work/hasura/graphql-engine$ docker run --rm -it --network host --name hasura-server -v`pwd`:`pwd` -w`pwd`/server/tests-py hasura/graphql-engine-server-builder:20190507-1 sh
# pip3 install -r requirements.txt
# pytest -vv --hge-url="http://localhost:8080" --pg-url="postgres://postgres:password@localhost:6432/postgres" test_events.py
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
-- | Lists that are of finite length.
module Data.List.Finite
@chrisdone
chrisdone / limitChunks.hs
Last active May 2, 2019 09:40
Limit chunks consumed in attoparsec
{-# LANGUAGE BangPatterns #-}
{-
Limit the number of chunks used to consume a given thing.
> feeder 5 (parse (limitChunksConsumed 1 jstring)) ("\"hello world\"")
Chunk [34,104,101,108,108]
Waiting for more ...
Chunk [111,32,119,111,114]
Waiting for more ...
@chrisdone
chrisdone / 0.md
Last active April 24, 2019 08:34
Prana demonstration

This is a simple demonstration of what Prana is currently capable of doing:

  1. The script generate.sh will compile
  • ghc-prim
  • integer-gmp
  • base
  1. The binary prana-ghc acts as a replacement for regular ghc, but it also "Recompiles" and outputs .prana files
  2. The resulting "object" .prana files contain STG for each library, and they go in the PRANA_DIR directory
  3. Along with an "index" file that maps numerical references of variables/nodes/data constructors to strings like package:Module.name.
  4. That whole process takes about 15 seconds.
@chrisdone
chrisdone / 0_fib-iter.hs
Last active April 23, 2019 13:33
Fibs in Prana
fib :: Int -> Int
fib n = go 0 1 0
where
go !acc0 !acc1 !i
| i == n = acc0
| otherwise = go acc1 (acc0 + acc1) (i + 1)
it :: Int
it = fib 50

Example use:

> import Network.HTTP.Simple
> import qualified Data.ByteString.Char8 as B8
> :set -XOverloadedStrings
> import Data.String
> withWebService (responseBs "Hello!") (\port -> httpBS (fromString ("http://localhost:" ++ show port)) >>= B8.putStrLn . getResponseBody)
Hello!
>