(defmacro def-vars [sym & exprs]
`(do
~@(map-indexed (fn [i exp] `(def ~(symbol (str sym i)) ~exp))
exprs)))
Example Usage: (def-vars x (+ 1 2) 3 (* 2 5))
defines global variables x0
, x1
, x2
.
(defn recursive-map [f coll] | |
;; is seq? right check?? | |
;; it may not work for vectors | |
;; is there a coll? function? | |
(if (seq? coll) | |
(map #(recursive-map f %) coll) | |
coll))) |
(defmacro my-doto [obj-expr & exprs] | |
(let [obj-sym (gensym "object") | |
actions (for [[method & args] exprs] | |
`(~method ~obj-sym ~@args))] | |
`(let [~obj-sym ~obj-expr] | |
~@actions | |
~obj-sym))) | |
;; Example | |
(my-doto (java.util.HashMap.) |
(defn print-inverted-triangle | |
"Print inverted triangle of given size, i.e., | |
the top right triangular half of a square of given size | |
Example: `(print-inverted-triangle 5)` prints: | |
``` | |
***** | |
**** | |
*** | |
** |
Forth is an old stack-based language, primarily used in embedded / resource-constrained environments. I watched this Forth intro talk.
All config, credentials are stored by aws
in ~/.aws
.
Note: In any command, a variable written in all capital (example: SSO-PROFILE-NAME
) has to be replaced by the appropriate value.
The official docs only show how to install aws-cli
as root user. If you don't have root access, you can follow these steps:
from __future__ import annotations | |
class Dummy: | |
""" | |
Class for a dummy object, where we can do arbitary attribute / item / method chaining - all of them always return the object itself. | |
Can also be called as a function, with any arguments or keyword arguments - again, the object itself is always returned. | |
>>> obj = Dummy() | |
>>> obj.x.y.z['key']('surprise', my='hurrah!') is obj |
# Source: https://stackoverflow.com/a/71542036/12947681 | |
Get-ChildItem '.' -R -Filter *.zip | ForEach-Object { | |
Expand-Archive $_.FullName "$($_.DirectoryName)/$($_.Basename)" -Force | |
Remove-Item $_.FullName | |
} |