Skip to content

Instantly share code, notes, and snippets.

View shapr's full-sized avatar
🏃
VENTRE À TERRE

Shae Erisson shapr

🏃
VENTRE À TERRE
View GitHub Profile
data GithubConfig = GC {
username :: Text
, oauth :: Text
} deriving (Show, Eq, Ord)
githubSpec :: ValueSpec GithubConfig
githubSpec = sectionsSpec "github" $
do username <- reqSection "username" "GitHub username"
oauth <- reqSection "oauth" "OAuth Token for GitHub"
pure GC{..}
@shapr
shapr / Data.hs
Last active September 15, 2019 20:03
share [mkMigrate "migrateAll", mkPersist sqlSettings] [persistLowerCase|
Paper json
doi Text
author Text
published Day
title Text
Primary doi
UniquePaperDoi doi
deriving Show Generic
Annotation json
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Data.Attoparsec.Text
import Data.Char (isLetter)
import qualified Data.Map.Strict as M
import Data.Text hiding (foldr, zipWith)
{-
@shapr
shapr / Env.hs
Created September 7, 2019 20:54
lookup environment variables, some of which do not exist. Handle whether exists or not.
module Main where
-- using http://hackage.haskell.org/package/base-4.12.0.0/docs/System-Environment.html#v:lookupEnv
import System.Environment
main :: IO ()
main = do
shell <- lookupEnv "SHELL" -- System.Environment.lookupEnv take a String
doesnotexist <- lookupEnv "DOESNOTEXIST"
print (checkEnvVars shell)
@shapr
shapr / whonknows.cabal
Created September 3, 2019 20:36
a basic cabal package config file
cabal-version: >=1.10
name: whonknows
version: 0.1.0.0
license: BSD3
license-file: LICENSE
author: Shae Erisson
maintainer: [email protected]
build-type: Simple
extra-source-files: CHANGELOG.md
[env:teensy36]
platform = teensy
board = teensy36
framework = arduino
build_flags = -D USB_EVERYTHING
lib_deps =
/home/shae/build/Tympan_Library
https://github.com/PaulStoffregen/Audio.git
https://github.com/PaulStoffregen/SD.git
https://github.com/PaulStoffregen/SPI.git
{-# LANGUAGE TypeApplications #-}
module Main where
import Data.SBV
main = do
res <- optimize Lexicographic configure
print res
configure :: Goal
@shapr
shapr / vmonhost.scm
Created July 8, 2019 21:20
fitting VMs into hosts
;; declare a cartesian product of host server and VM
;; three VMs x1, x2, x3 and three hosts y1, y2, y3
(declare-const x11 Int) ; VM x1 might be on host y1
(declare-const x12 Int) ; VM x1 might be on host y2
(declare-const x13 Int)
(declare-const x21 Int) ; VM x2 might be on host y1
(declare-const x22 Int)
(declare-const x23 Int)
(declare-const x31 Int)
(declare-const x32 Int)
@shapr
shapr / CreateGitHubRepo.hs
Created June 25, 2019 21:58
remotely create github repo with the v3 API
{-# LANGUAGE OverloadedStrings #-}
module Main where
import GitHub.Endpoints.Repos
-- https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line
-- give the token "public_repo" access
-- should be a 40 character string
myauth = OAuth "80....................................2e" -- magically converts to ByteString
@shapr
shapr / EndlessSky.hs
Created June 21, 2019 16:46
how to describe SMT problems?
module Main where
import Data.SBV
-- main :: IO ()
main = do
res <- optimize Lexicographic $ do
-- create two piles of bools, each pile has a bool for each possible component
-- x1@[x11, x12, x13] <- sBools ["x11", "x12", "x13"]
-- map the costs onto the bools?!