From 84baf901476f57731ebcd64dca4acc98e0b8921f Mon Sep 17 00:00:00 2001 From: Willem van den Ende Date: Sun, 21 Mar 2021 21:03:22 +0000 Subject: [PATCH] Long time, no commits --- config.el | 87 ++++++++++++++++++++ custom.el | 1 + init.el | 11 ++- snippets/json-mode/AWS CodeBuild json config | 55 +++++++++++++ snippets/json-mode/__code_build.json | 55 +++++++++++++ snippets/markdown-mode/jekyll blog post | 12 +++ snippets/yaml-mode/___buildspec.yml | 28 +++++++ 7 files changed, 245 insertions(+), 4 deletions(-) create mode 100644 snippets/json-mode/AWS CodeBuild json config create mode 100644 snippets/json-mode/__code_build.json create mode 100644 snippets/markdown-mode/jekyll blog post create mode 100644 snippets/yaml-mode/___buildspec.yml diff --git a/config.el b/config.el index 6144602..a4725f8 100644 --- a/config.el +++ b/config.el @@ -59,3 +59,90 @@ ;; ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how ;; they are implemented. +;; + + +(setq evil-move-cursor-back nil) + +;; +;; from https://github.com/org-roam/org-roam-server/issues/115 +;; but modified the open to browse-url-button-open-url +(use-package org-roam-server + :config + (setq org-roam-server-host "127.0.0.1" + org-roam-server-port 8427 + org-roam-server-authenticate nil + org-roam-server-export-inline-images t + org-roam-server-serve-files nil + org-roam-server-served-file-extensions '("pdf" "mp4" "ogv") + org-roam-server-network-poll t + org-roam-server-network-arrows nil + org-roam-server-network-label-truncate t + org-roam-server-network-label-truncate-length 60 + org-roam-server-network-label-wrap-length 20)) + +(defun org-roam-server-open () + "Ensure the server is active, then open the roam graph." + (interactive) + (org-roam-server-mode 1) + (browse-url-button-open-url (format "http://localhost:%d" org-roam-server-port))) + +(after! org-roam + (org-roam-server-mode)) + +;; two functions from: +;; https://zzamboni.org/post/my-emacs-configuration-with-commentary/#reformatting-an-org-buffer +(defun zz/org-reformat-buffer () + (interactive) + (when (y-or-n-p "Really format current buffer? ") + (let ((document (org-element-interpret-data (org-element-parse-buffer)))) + (erase-buffer) + (insert document) + (goto-char (point-min))))) + +(defun afs/org-remove-link () + "Replace an org link by its description or if empty its address" + (interactive) + (if (org-in-regexp org-link-bracket-re 1) + (let ((remove (list (match-beginning 0) (match-end 0))) + (description (if (match-end 3) + (org-match-string-no-properties 3) + (org-match-string-no-properties 1)))) + (apply 'delete-region remove) + (insert description)))) + +(defun qwan/org-replace-link-by-link-description () + "Remove the link part of an org-mode link at point and keep +only the description" + (interactive) + (let ((elem (org-element-context))) + (if (eq (car elem) 'link) + (let* ((content-begin (org-element-property :contents-begin elem)) + (content-end (org-element-property :contents-end elem)) + (link-begin (org-element-property :begin elem)) + (link-end (org-element-property :end elem))) + (if (and content-begin content-end) + (let ((content (buffer-substring-no-properties content-begin content-end))) + (delete-region link-begin (- link-end 1)) + (insert content))))))) +(bind-key "C-c r" 'qwan/org-replace-link-by-link-description) + +(defun org-roam-replace-file-link-by-website-or-description () + "If a linked org-roam file has a website as key, use that as the link target instead of the filename. Otherwise, remove the link, and leave just +the description. This may destroy existing links, or change their targets so use in a copy of buffers you hold dearly as notes" + (interactive) + (let ((elem (org-element-context))) + (if (eq (car elem) 'link) + (let* ((content-begin (org-element-property :contents-begin elem)) + (content-end (org-element-property :contents-end elem)) + (target-type (org-element-property :type elem)) + (target-path (org-element-property :path elem)) + (link-begin (org-element-property :begin elem)) + (link-end (org-element-property :end elem))) + (if (and content-begin content-end (string-equal target-type "file") target-path link-begin link-end) + (let ((new-link (org-roam-description-file-to-org-url + (buffer-substring-no-properties content-begin content-end) + target-path))) + (delete-region link-begin (- link-end 1)) + (insert new-link) + )))))) diff --git a/custom.el b/custom.el index 4c74d01..e88fa30 100644 --- a/custom.el +++ b/custom.el @@ -10,3 +10,4 @@ ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) +(put 'downcase-region 'disabled nil) diff --git a/init.el b/init.el index 56adc0b..f7c05db 100644 --- a/init.el +++ b/init.el @@ -14,6 +14,9 @@ ;; Alternatively, press 'gd' (or 'C-c c d') on a module to browse its ;; directory (for easy access to its source code). + +;; Regular configuration +;; (doom! :input ;;chinese ;;japanese @@ -76,7 +79,7 @@ ;;eshell ; the elisp shell that works everywhere ;;shell ; simple shell REPL for Emacs ;;term ; basic terminal emulator for Emacs - ;;vterm ; the best terminal emulation in Emacs + vterm ; the best terminal emulation in Emacs :checkers syntax ; tasing you for every semicolon you forget @@ -87,7 +90,7 @@ ;;ansible ;;debugger ; FIXME stepping through code, to help you add bugs ;;direnv - ;;docker + docker ;;editorconfig ; let someone else argue about tabs vs spaces ;;ein ; tame Jupyter notebooks with emacs (eval +overlay) ; run code, run (also, repls) @@ -146,7 +149,7 @@ ;;nim ; python + lisp at the speed of c ;;nix ; I hereby declare "nix geht mehr!" ;;ocaml ; an objective camel - (org +roam ) ; organize your plain life in plain text + (org +roam +download-dnd) ; organize your plain life in plain text ;;php ; perl's insecure younger brother plantuml ; diagrams for confusing people more ;;purescript ; javascript, but functional @@ -166,7 +169,7 @@ ;;swift ; who asked for emoji variables? ;;terra ; Earth and Moon in alignment for performance. ;;web ; the tubes - ;;yaml ; JSON, but readable + yaml ; JSON, but readable :email ;;(mu4e +gmail) diff --git a/snippets/json-mode/AWS CodeBuild json config b/snippets/json-mode/AWS CodeBuild json config new file mode 100644 index 0000000..91a8b94 --- /dev/null +++ b/snippets/json-mode/AWS CodeBuild json config @@ -0,0 +1,55 @@ +# key: __codebuild.json +# name: AWS CodeBuild json config +# -- +{ + "name": "$1", + "arn": "arn:aws:codebuild:eu-central-1:123456789012:project/$2" + "description": "$3", + "source": { + "type": "CODEPIPELINE", + "insecureSsl": false + }, + "secondarySourceVersions": [], + "artifacts": { + "type": "CODEPIPELINE", + "name": "$4", + "packaging": "NONE", + "encryptionDisabled": false + }, + "cache": { + "type": "NO_CACHE" + }, + "environment": { + "type": "LINUX_CONTAINER", + "image": "aws/codebuild/standard:5.0", + "computeType": "BUILD_GENERAL1_SMALL", + "environmentVariables": [ + { + "name": "AWS_DEFAULT_REGION", + "value": "eu-central-1", + "type": "PLAINTEXT" + } + ], + "privilegedMode": true, + "imagePullCredentialsType": "CODEBUILD" + }, + "serviceRole": "arn:aws:iam::123456789012:role/ExampleCodeBuildServiceRole", + "timeoutInMinutes": 60, + "queuedTimeoutInMinutes": 480, + "encryptionKey": "arn:aws:kms:eu-central-1:123456789012:alias/aws/s3", + "tags": [$5], + "badge": { + "badgeEnabled": false + }, + "logsConfig": { + "cloudWatchLogs": { + "status": "ENABLED" + }, + "s3Logs": { + "status": "DISABLED", + "encryptionDisabled": false + } + }, + "fileSystemLocations": [], + "concurrentBuildLimit": 1 +} \ No newline at end of file diff --git a/snippets/json-mode/__code_build.json b/snippets/json-mode/__code_build.json new file mode 100644 index 0000000..31ddf75 --- /dev/null +++ b/snippets/json-mode/__code_build.json @@ -0,0 +1,55 @@ +# key: __codebuild.json +# name: AWS CodeBuild json config +# -- +{ + "name": "course-vendingmachine-cs", + "arn": "arn:aws:codebuild:eu-central-1:123456789012:project/$1" + "description": "$2", + "source": { + "type": "CODEPIPELINE", + "insecureSsl": false + }, + "secondarySourceVersions": [], + "artifacts": { + "type": "CODEPIPELINE", + "name": "$3", + "packaging": "NONE", + "encryptionDisabled": false + }, + "cache": { + "type": "NO_CACHE" + }, + "environment": { + "type": "LINUX_CONTAINER", + "image": "aws/codebuild/standard:5.0", + "computeType": "BUILD_GENERAL1_SMALL", + "environmentVariables": [ + { + "name": "AWS_DEFAULT_REGION", + "value": "eu-central-1", + "type": "PLAINTEXT" + } + ], + "privilegedMode": true, + "imagePullCredentialsType": "CODEBUILD" + }, + "serviceRole": "arn:aws:iam::123456789012:role/ExampleCodeBuildServiceRole", + "timeoutInMinutes": 60, + "queuedTimeoutInMinutes": 480, + "encryptionKey": "arn:aws:kms:eu-central-1:123456789012:alias/aws/s3", + "tags": [$4], + "badge": { + "badgeEnabled": false + }, + "logsConfig": { + "cloudWatchLogs": { + "status": "ENABLED" + }, + "s3Logs": { + "status": "DISABLED", + "encryptionDisabled": false + } + }, + "fileSystemLocations": [], + "concurrentBuildLimit": 1 +} \ No newline at end of file diff --git a/snippets/markdown-mode/jekyll blog post b/snippets/markdown-mode/jekyll blog post new file mode 100644 index 0000000..eaaa81c --- /dev/null +++ b/snippets/markdown-mode/jekyll blog post @@ -0,0 +1,12 @@ +# -*- mode: snippet -*- +# name: jekyll blog post +# key: jekyll_post +# -- +--- +layout: post +title: $0 +tags: + - $1 +author: Willem van den Ende +image: $2 +--- \ No newline at end of file diff --git a/snippets/yaml-mode/___buildspec.yml b/snippets/yaml-mode/___buildspec.yml new file mode 100644 index 0000000..e6d9720 --- /dev/null +++ b/snippets/yaml-mode/___buildspec.yml @@ -0,0 +1,28 @@ +# -*- mode: yaml -*- +# name: AWS CodeBuild buildspec +# key: buildspec +# -- + +version: 0.2 + +phases: + pre_build: + commands: + - echo Logging in to Amazon ECR... + - aws --version + - aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.eu-central-1.amazonaws.com + - REPOSITORY_URI=123456789012.dkr.ecr.eu-central-1.amazonaws.com/example/$1 + - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) + - IMAGE_TAG=${COMMIT_HASH:=latest} + build: + commands: + - echo Build started on `date` + - echo Building the Docker image... + - docker build -t $REPOSITORY_URI:latest . + - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG + post_build: + commands: + - echo Build completed on `date` + - echo Pushing the Docker images... + - docker push $REPOSITORY_URI:latest + - docker push $REPOSITORY_URI:$IMAGE_TAG