Skip to content

Instantly share code, notes, and snippets.

View mprokopov's full-sized avatar

Maksym Prokopov mprokopov

View GitHub Profile
@mprokopov
mprokopov / xenserver_vm.tf
Created December 4, 2023 13:59
XenServer Terraform Example
provider "xenserver" {
url = "https://xxx.xxx.xxx.xxx"
username = "root"
password = ""
}
# resource "xenserver_vm" "test1" {
# base_template_name = "sample-template"
# name_label = "test1"
# static_mem_min = 2147483648
@mprokopov
mprokopov / import.bb
Created December 4, 2023 13:52
babushka generate dips.edn out of project.clj
#!/usr/bin/env bb
(ns switch
(:require [clojure.pprint :as pprint]))
(defn project-clj-map [filename]
(->> (slurp filename)
(read-string)
(drop 1)
(partition 2)
(map vec)
@mprokopov
mprokopov / docker-credentials-1password-helper.clj
Created October 16, 2022 18:20
Docker helper to provision AWS token from AWS credentials stored in 1Password Connect.
#!/usr/bin/env bb
;; 0. run using 1Password CLI "op inject -i docker-credentials-1password -o docker-credentials-1password" to replace
;; reference to op://Personal/1P token/credential with real 1Password Connect token.
;; http://onepasswordconnect.local/v1/vaults/vault_uuid/items/item_uuid should point to your 1Password Connect, vault and item with AWS credentials.
;; 1. save to /usr/local/bin/docker-credentials-1password;
;; 2. install babashka from http://babashka.org
;; 3. create /etc/docker/config.json
;; { "credsStore": "1password" }
;; 4. install docker-credentials-ecr-login from https://github.com/awslabs/amazon-ecr-credential-helper
;; 5. docker pull xxxxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/my-great-repo should just work now!
@mprokopov
mprokopov / time.clj
Created June 29, 2021 11:31
clojure time span at beginning of the month and at the end of the month
(def now (java.time.LocalDateTime/now))
(-> now
(.with (java.time.temporal.TemporalAdjusters/firstDayOfMonth))
(.with (java.time.LocalTime/MIN)))
(-> now
(.with (java.time.temporal.TemporalAdjusters/lastDayOfMonth))
(.with (java.time.LocalTime/MAX)))
@mprokopov
mprokopov / bb-mysql.clj
Created May 21, 2021 10:23
babashka honeysql with mysql example
;; CREATE TABLE `station` (
;; `id` int(11) NOT NULL AUTO_INCREMENT,
;; `location` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
;; PRIMARY KEY (`id`)
;; ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
;; CREATE TABLE `rental_order` (
;; `id` int(11) NOT NULL AUTO_INCREMENT,
;; `campervan_id` int(11) NOT NULL,
;; `start_station_id` int(11) NOT NULL,
;; `end_station_id` int(11) NOT NULL,
@mprokopov
mprokopov / Vagrantfile
Created May 5, 2021 09:28
prep vagrant for devops courses with ansible, k8s and jenkins
Vagrant.configure("2") do |config|
## VM for target deployments
config.vm.define "target", autostart: false do |target|
target.vm.box = "centos/7"
target.vm.network "forwarded_port", guest: 8000, host: 8000
target.vm.network "private_network", ip: "10.10.50.3"
target.vm.provider "virtualbox" do |vb|
vb.memory = "512"
end
#target.vm.synced_folder "../target_home_folder", "/home/vagrant/target"
@mprokopov
mprokopov / datafy_datomic.clj
Created April 2, 2021 17:29
datomic datafy
(extend-protocol clojure.core.protocols/Datafiable
datomic.query.EntityMap
(datafy [o] (into {} o)))
(extend-protocol clojure.core.protocols/Navigable
datomic.query.EntityMap
(nav [coll k v]
(clojure.datafy/datafy v)))
@mprokopov
mprokopov / rebl_tap.clj
Created April 2, 2021 17:01
cognitect rebl tap
(require '[cognitect.rebl])
(cognitect.rebl/ui)
(add-tap #'cognitect.rebl/submit)
(tap> [1 2 3])
@mprokopov
mprokopov / tap.clj
Created April 2, 2021 15:29
example of calling tap> function and return value. Useful when used with chain operators
(def get-account
(interceptor/handler
(fn [{db :db user-id :user/id}]
(let [pull-exp [::account/id
::account/balance
{::account/currency [::currency/name
::currency/minor-unit
::currency/description]}]]
(ok
(->