LIST

edit current terminal command in vim

type something in terminal then trigger the edit in vim mode ctrl x ctrl e edit stuff in vim exit vim :wq

June 6, 2023

circleci pipeline failed notification in google chat (aka gchat, hangouts)

.circleci/config.yml workflows: main: jobs: - xxx - yyy: requires: - xxx commands: notify_failure: description: Notify our gchat channel about the failure steps: - run: name: Notify failure command: ./.circleci/scripts/notify_chat_about_pipeline_failure.sh when: "on_fail" jobs: xxx: steps: - run: echo "step 1" - run: echo "step 2" - notify_failure yyy: steps: - run: echo "step a" - run: echo "step b" - notify_failure .circleci/scripts/notify_chat_about_pipeline_failure.sh #!/usr/bin/env bash message="pipeline failed: branch '$CIRCLE_BRANCH' job: $CIRCLE_JOB committer: @${CIRCLE_USERNAME} url: $CIRCLE_BUILD_URL " curl \ --request POST \ --header "Content-Type: application/json" \ --data "{\"text\":\"$message\"}" \ "$CHAT_WEBHOOK_URL" you can get the webhook url in google chat by gchat channel -> Apps & Integrations -> manage webhooks...

March 24, 2023

google cloud function go GCP

package function import ( "fmt" "net/http" "github.com/GoogleCloudPlatform/functions-framework-go/functions" ) func init() { functions.HTTP("HelloWorld", helloWorld) } // helloWorld writes "Hello, World!" to the HTTP response. func helloWorld(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Hello, World!") } so then your entry_point = “HelloWorld” That is the entrypoint from the init() NOT the function name inspiration: Write Cloud Functions _ Cloud Functions Documentation _ Google Cloud GoogleCloudPlatform_functions-framework-go_ FaaS (Function as a service) framework for writing portable Go functions

March 22, 2023

Course: Go: The Complete Developer's Guide (Golang) - Stephen Grider

udemy.com/course/go-the-complete-developers-guide https://github.com/StephenGrider/GoCasts Hello world package main import "fmt" func main(){ fmt.Println("Hello world!") } go run main.go go build # compile files go run # compile + execute go fmt # format all files in PWD # dependencies: go install # install a package go get # download raw src coude go test # run tests package ~= project package main -> executable package not_main -> library package main MUST have...

March 14, 2023

GCP create config account

create config (only once) #show state before gcloud config configurations list gcloud config configurations create "MY_PROFILE" export CLOUDSDK_ACTIVE_CONFIG_NAME="MY_PROFILE" gcloud config set core/project "MY_GCP_PROJECT" gcloud config set core/account "MY_EMAIL" #show state after gcloud config configurations list use config (every terminal session) # choose project export CLOUDSDK_ACTIVE_CONFIG_NAME="MY_PROFILE" # login (valid for about an hour) export GOOGLE_OAUTH_ACCESS_TOKEN="$(gcloud auth print-access-token)"

March 10, 2023

run terraform as a service account

grant permission to a group / user resource "google_service_account_iam_member" "allow_us_to_impersonate" { service_account_id = google_service_account.service_account.id role = "roles/iam.serviceAccountTokenCreator" member = "group:GOOGLE_GROUP_EMAIL" } run terraform as a service account # run as service account export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT="SERVICE_ACCOUNT_EMAIL" # stop running as service account export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT=""

March 10, 2023

micronaut library standalone project

Don’t follow this if you can make a gradle submodule. That is much simpler This is for adding a local project as an instant dependency. a) How to add micronaut library inspired by Modularizing with Micronaut Framework _ kreuzwerker but changing to import a local project instead of using lib/xxx.jar b) How to add a local standalone gradle project inspired by java - Gradle Local Project Dependency - Stack Overflow but change compile project("…") to implement project("…")...

February 14, 2023

AWS & Typescript Masterclass - 10. Using AWS inside a React project with Amplify

82-93 (82) Section intro introduce AWS Amplify in the browser Get temporary credentials in the Browser CORS issues App will be approaching it’s final form (83) Setup and Amplify install npm i aws-amplify @aws-amplify/auth npm i aws-sdk (84) Cognito login from React code model.ts import {CognitoUser} from '@aws-aplify/auth' export interface User { userName: string cognitoUser: CognitoUser } service/AuthService import {Auth} from "aws-amplify"; import Amplify from "aws-amplify"; import {CognitoUser} from "@aws-amplify/auth"; import {config} from "....

September 17, 2022

AWS & Typescript Masterclass - 9. Front-end for our back-end with React

62-81 (63) Create react app and git npx create-react-app space-finder-frontend --template typescript (64) Basic project structure folder structure components: ui components (*.tsx) model: types (*.ts) services: non-ui code (*.ts) util (*.ts) (65) state, props, child, parent change in state or props triggers re-render props are immutable state is mutable this.setState({ counterState: this.state.counterState + 1 }) use state / props this.state.counterState this.props.counterProp typescript class defines type of Props and State interface Props { counterProp: number } interface State { counterState: number } export class MyComponent extends React....

September 17, 2022

AWS & Typescript Masterclass - 11. Application Development

(Section 11 of Course_ AWS & Typescript Masterclass - CDK, Serverless, React) 94-97 (95) Deployment to S3 and Cloudfront // create bucket this.deploymentBucket = new Bucket( this.stack, 'space-app-web-id', { bucketName: bucketName, publicReadAccess: true, websiteIndexDocument: 'index.html' } ); new CfnOutput(this.stack, 'spaceFinderWebAppS3Url', { value: this.deploymentBucket.bucketWebsiteUrl }); // upload build folder to the bucket new BucketDeployment( this.stack, 'space-app-web-id-deployment', { destinationBucket: this.deploymentBucket, sources: [ Source.asset( join(__dirname, '..', '..', 'space-finder-frontend', 'build') ) ] } ); // cloudfront const cloudFront = new CloudFrontWebDistribution( this....

September 16, 2022