Redefine ENV variable inside a EDN file using aero - clojure

I'm trying to redefine a value of an env variable inside an EDN file in order to write some tests.
Basically, I have an EDN file (simplified here) like this:
{:foo #include #or [#env SOME_VAR "default.edn"]}
Here I am using https://github.com/juxt/aero in order to have these tag literals (#include, #or and #env)
Aero handles the #env thing using System/getenv, so I tried to use with-redefs to temporarily redefines it, but without success.
So, any tip here on how to do it?
Thanks in advance

Related

How do I add comments to my config file using QSettings?

I'm writing a c++ code using qt and need an editable config file for my user to change some settings. In order to provide him some additional information I would like to add comments to my config file, however I cant find a way to mark them as comments.
I am using QSettings, my file is a .flt file. The usual '#' unfortunately does not seem to work with QSettings.
when using setting files in Qt and the QSettings class, you don't use the "usual"
#
for defining a comment, but the
;
instead...
so:
[abc]
key=val
;this is a comment in the QSettings
flag=true
QSetting's INI file format uses MS Windows file format, which is
a) hierarchical and uses brackets [] for section names
b) uses ; to designate comment lines.
Note, thr default engine of QSetting would wipe any comments, because the whole mechanism is just serialization of name-value pairs from file and to file. To avoid that, a custom reader-writer class should be devised which would read and preserve comments somehow. QSettings supports custom formats by offering interface for read and write functions.

How to eval in a repl all forms in a file in Idea Cursive plugin for Clojure?

There is an "eval form hotkey", so if I manually eval each top-level form in a file I get what I want eventually. But I can't find a way to eval all forms at once. Sometimes form a depends on b which depends on c and manual evaluation is not convenient. Is that possible?
Set your shortcut for Load file in REPL in keymap(Preferences)

python tkinter using variables across files,?

I have been playing with Tkinter in Python 2.7, and just ran across something that SHOULD be a bug, but isn't and the program seems to work OK still.
To make my program more manageable, I have split it into separate .py files.
One file (called globs.py) is a list of global variables in the form
global var_1
global var_2
...
Then I import globs into my other files.
In another file I can set the variable, thus...
import globs
globs.var_1 = "some value"
In a third file I can use it..
import globs
if globs.var_1 == "something":
...
So far, all is as expected, but...
I just found out if the variable is NOT mentioned in the globs.py file at all, the program still seems to work OK.
Is this intended behavior? Any other programming language would give a 'variable not found' error.
If it is intended, why should I even setup any variables in globs.py?
What are the drawbacks?
Thanks, Mark.

How to add custom variables in haxe templates?

Haxe takes some templates to bin folder when it compiles. It process templates, replacing variables in it ::WIN_WIDTH:: with values 640. It can also take your custom templates like so:
<template path="your/template.txt" rename="tmpl.txt"/>
I would like to know is there any way to place your own variables ::myvar:: in those templates?
EDIT
http://old.haxe.org/doc/cross/template - Unfortunately, that article only explains how to execute haxe.Template class instances. In the end you will get the string (your processed template).
What I want is to add my custom placeholders to default haxe templates, such as OpenFL Android project templates. I need Haxe to process it's templates WITH my own placeholders and outputs it in the bin folder, as usually does.
I had to figure it out the hard way, but it turns out that the <setenv> tag really works as advertised.
In project.xml:
<setenv name="MY_VAR" value="612" />
In template.txt:
::if ENV_MY_VAR::
The value of MY_VAR is ::ENV_MY_VAR::.
::else::
MY_VAR is not defined.
::end::
You could also define it as "myvar", but then you'd have to use "ENV_myvar" in template.txt.
http://old.haxe.org/doc/cross/template
this explain everything about templates, how to use variables and things like if and foreach.

How to implement per user .emacs style config in clojure application?

I have a Clojure application which process some data in our company. So I want to obtain possibility of its customization throw .myapp.clj file or something like this.
It must be a simple script in clojure in which user can define own data processing principle. Also he must has possibility for tunning http back end and others application parts.
So, what is the best way to implement this fiche?
A couple ways come to mind with varying levels of sophistication. The simplest is to just have each user define a ~/.myall.clj in their home directory and then the start of the program would include a line:
(def per-user-config (load-file "~/.myall.clj"))
load-file reads a file and returns the last form read in the file. This allows you to compose config files nicely. For instance you can make a company wide template that has symbols for things like user-name and then load it from a per-user config file that defines user-name and then calls load-file on the template
config-template.clj:
{:app-name "foo"
:user-url (str "http://server.company:8080/users/" user-name)
:foo "bar"}
joes-config.clj:
(def user-name "joe")
(load-file "resources/global-config.clj")
this allows you to distribute most of the config through git while still allowing users to overwrite any arbitrary part of the config.