Skip to content

Instantly share code, notes, and snippets.

View jzxhuang's full-sized avatar

Jeff Huang jzxhuang

View GitHub Profile
@jzxhuang
jzxhuang / ecelinux.md
Last active March 31, 2024 01:30
ECE Linux SSH + VS Code Configuration

ECE Linux SSH + VS Code Setup Guide

How to set up SSH for ECE linux "the right way". No VPN is required to SSH into ECE linux. Notably, with this setup:

  • Skip eceterm completely and go directly to eceubuntu/ecetesla - you only need to type the SSH command ONCE (and enter your password ONCE).
  • Configure VS Code to work over SSH. Edit remote files while maintaining your VS Code features like Intellisense, syntax highlighting, themes, etc.

Skip to the bottom of the document for a summary (TL;DR).

Disclaimer: I have only tested on macOS. It should work fine for *nix systems, but not sure about Windows. The instructions are up-to-date as of the last update of the Gist. Some Windows-specific notes are included in some sections thanks to feedback from classmates using Windows.

/*
██████╗ ██╗ ██████╗ ██████╗██╗ ██╗██╗ ██╗
██╔══██╗██║ ██╔═══██╗██╔════╝██║ ██╔╝╚██╗ ██╔╝
██████╔╝██║ ██║ ██║██║ █████╔╝ ╚████╔╝
██╔══██╗██║ ██║ ██║██║ ██╔═██╗ ╚██╔╝
██████╔╝███████╗╚██████╔╝╚██████╗██║ ██╗ ██║
╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝ ╚═╝
*/
Approach Difficulty Custom Errors Any Method Advanced Behaviour? Comments
Static Files Very Easy No No No N/A
"Unboxing" Response Medium Yes No No N/A
Mocking Within Elm Medium Yes Yes No May increase size of application
Mock Server Hard Yes Yes Yes N/A
expectStringResponseMocked : Response String -> (Result x a -> msg) -> (Response String -> Result x a) -> Http.Expect msg
expectStringResponseMocked mockResponse toMsg transformer =
Http.expectStringResponse toMsg <|
\_ -> transformer mockResponse
import Http
import Json.Decode as D
expectJson : (Result Http.Error a -> msg) -> D.Decoder a -> Expect msg
expectJson toMsg decoder =
expectStringResponse toMsg <|
\response ->
case response of
Http.BadUrl_ url ->
Err (Http.BadUrl url)
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
{
"responseType": "Normal",
"metadata": {
"url": "http://example.com",
"statusCode": 401,
"statusText": "Unauthorized",
"headers": {}
},
"body": "Invalid username or password."
}
{
"data": {
"id": 2,
"first_name": "Janet",
"last_name": "Weaver",
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/josephstein/128.jpg"
}
}
getPost : Model -> (Result Http.Error String -> msg) -> Int -> Cmd msg
getPost model msg postId =
let
url =
model.apiUrl
++ "/posts/"
++ String.fromInt postId
++ (if model.environment == "mock" || model.environment == "test" then
".json"
@jzxhuang
jzxhuang / ExpectStringDetailed_Improved.elm
Created April 4, 2019 07:43
ExpectStringDetailed handling success and error case
expectStringDetailed : (Result DetailedError ( Metadata, String ) -> msg) -> Expect msg