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
-- https://wiki.haskell.org/Parsing_a_simple_imperative_language | |
-- currently doesn't support floating point or functions. | |
module Main where | |
import System.IO | |
import Control.Monad | |
import Text.ParserCombinators.Parsec | |
import Text.ParserCombinators.Parsec.Expr | |
import Text.ParserCombinators.Parsec.Language | |
import qualified Text.ParserCombinators.Parsec.Token as Token |
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
use rsc::{tokenize, parse, Interpreter, TokenizeError, ParseError, InterpretError}; | |
// error handling based on: | |
// * https://doc.rust-lang.org/rust-by-example/error/multiple_error_types/wrap_error.html | |
#[derive(Debug)] | |
struct EquationError(pub String); | |
impl<'input_string> From<TokenizeError<'input_string>> for EquationError { | |
fn from(err: TokenizeError<'input_string>) -> EquationError { |
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
use std::fmt; | |
use rsc::{tokenize, parse, Interpreter, TokenizeError, ParseError, InterpretError}; | |
// error handling based on: | |
// * https://doc.rust-lang.org/rust-by-example/error/multiple_error_types/wrap_error.html | |
// Unfortunately this didn't work in the context of `fn evaluate` as: | |
// 1) `cannot return value referencing local variable `tokens`` | |
// 2) `cannot return value referencing local variable `expr`` | |
// `ParseError` contains a reference to a Token rather than copy of it |
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
import { S3Client, PutObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3" | |
const s3client = new S3Client({logger: console}) |
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
https://jqplay.org | |
Transpose json into csv columns | |
see: https://stackoverflow.com/questions/48224065/jq-convert-json-file-with-arrays-to-csv-transposed | |
[.[]] | transpose[] | @csv | |
input: | |
{ |
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
# from: https://ericasadun.com/2019/11/19/taking-charge-of-those-xips/ | |
man -t grep | open -f -a /System/Applications/Preview.app | |
man -t open | open -f -a /System/Applications/Preview.app | |
# The -t flag tells man to use the Groff typesetter to format the page to postscript. This presents as a PDF in Preview. (Specifically, it uses /usr/bin/groff -Tps -mandoc -c if that kind of detail intrigues you.) |
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
private let dateFormatter:ISO8601DateFormatter = { | |
let formatter = ISO8601DateFormatter() | |
formatter.timeZone = TimeZone.current | |
formatter.formatOptions = [.withFullDate, .withFullTime, .withDashSeparatorInDate, .withColonSeparatorInTime, .withSpaceBetweenDateAndTime] | |
return formatter | |
}() | |
let date = dateFormatter.date(from: "2019-08-15 12:57:45 +0000") |
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 stack | |
-- stack runghc --resolver lts-12.4 --install-ghc --package wai-app-static --package warp | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Data.String | |
import Network.Wai.Application.Static (staticApp,defaultFileServerSettings) | |
import Network.Wai.Handler.Warp (runSettings, setPort, defaultSettings, run) |
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 stack | |
-- stack runghc --resolver lts-12.4 --install-ghc --package scotty --package wai --package warp --package wai-middleware-static | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
-- import Web.Scotty | |
-- import qualified Text.Blaze.Html5 as H | |
-- import Text.Blaze.Html5 (toHtml, 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
# Permissions to allow access to S3 console for read and write, see: | |
# https://stackoverflow.com/questions/6615168/is-there-an-s3-policy-for-limiting-access-to-only-see-access-one-bucket | |
# https://aws.amazon.com/blogs/security/writing-iam-policies-how-to-grant-access-to-an-amazon-s3-bucket/ | |
DeployUser: | |
Type: AWS::IAM::User | |
Properties: | |
UserName: 'aname@domain.com' | |
LoginProfile: | |
Password: apassword | |
# PasswordResetRequired: true |
NewerOlder