Laravel 9 use base_path() in .env file variable - environment-variables

There is a special string pattern to use base_path() into .env file variable ?
Something like : MY_PATH=%basePath%/my/path

Related

Dynamically use current date in OUTPUT EXPORT filename

Stripped down example code using a static file name:
OUTPUT EXPORT /CONTENTS EXPORT=ALL /PDF DOCUMENTFILE='example.pdf'
My question is how to generate a datestamped file. I have tried using $DATE, '$DATE' and running it through a macro but can't seem to find the syntax.
Hey this is a really nice Idea for saving backups in a running syntax production - I will use this myself from now on :) .
So the following syntax works for me:
compute tdy= $time.
formats tdy (date11).
temporary.
select if $casenum=1.
write out="somepath\datemacro.sps" /"define !dated__filename () !quote(!concat('YOUR FILE NAME',' ','", tdy, "','.pdf')) !enddefine.".
exe.
Insert file ="somepath\datemacro.sps".
delete vars tdy.
The file name you used in the code above is now stored in a macro with the date added, and you can use it here:
OUTPUT EXPORT /CONTENTS EXPORT=ALL /PDF DOCUMENTFILE= !dated__filename .
Note that you can change "YOUR FILE NAME" into anything you like, including adding a path. And you can also change ".pdf" so save other kinds of files.
EDIT: Also of course change "somepath" to a valid path on your machine.

Referring or passing variables within YAML file

I have the below sample YAML configuration. I'm trying to refer variables within same YAML file as below:
appname : delta
configrepo : dev
development:
clusterurl : "/sa1/demo/dfn"
email: pseudo#my-fdn.com
mount_dir: /mnt/tigers
app_config_dir: "/opt/tigers/$appname/$configrepo/svcaccount"
After reading YAML through Groovy into vardict when I try to do echo '$vardict.app_config_dir' I'm getting the values as below:
/opt/tigers///svcaccount
I'm looking for desired output as below:
/opt/tigers/delta/dev/svcaccount
Kindly suggest the correct way of referring the variables within single YAML file.
Thanks

bazel: Setting a global varible from environment variable

I need to use an environment variable in my bzl file. Right now its hardcoded like this
PI_TOOLCHAIN_ROOT_DIR = "/home/dev/oosman/.leila/toolchains/rpi"
I could probably read the environment variable in the _impl method below, but how do I set the global variable above.
def _impl(ctx):
#todo: need to get this env variable and use it instead of hardcoded paths where ever rpi is defined above
#PI_TOOLCHAIN_ROOT_DIR=${HOME}/${DOCKERUSER}/.leila/toolchains/rpi
#ctx.os.environ.get("PI_TOOLCHAIN_ROOT_DIR", "/home/dev/oosman/.leila/toolchains/rpi") #osm
https://github.com/jambamamba/libedgetpu/blob/raspi0/coral_crosstool1/cc_toolchain_config.bzl
Use a repository rule to generate a .bzl file. Something like this:
def _impl(repository_ctx):
repository_ctx.file("pi_toolchain_root.bzl", "PI_TOOLCHAIN_ROOT_DIR = \"%s\"" % \
repository_ctx.os.environ.get("PI_TOOLCHAIN_ROOT_DIR", "/home/dev/oosman/.leila/toolchains/rpi"))
pi_toolchain_repository = repository_rule(
implementation=_impl,
environ = ["PI_TOOLCHAIN_ROOT_DIR"],
)
Then in your WORKSPACE you can write:
load("//:wherever.bzl", "pi_toolchain_repository")
pi_toolchain_repository(name = "pi_toolchain")
and then (later on in WORKSPACE or in a BUILD or .bzl file):
load("#pi_toolchain//:pi_toolchain_root.bzl", "PI_TOOLCHAIN_ROOT_DIR")

In Xcode run-script how can I pring the real value from plist edited by xcconfig

I have my normal project and the default plist file, and I also created a xcconfig file.
First I added one key-value in my plist whose key is called custom_mode and value is connected to the value in xcconfig file like this:
//In .plist file
<dict>
<key>custom_mode</key>
<string>$(xcconfig_mode)</string>
</dict>
Second, in my xcconfig file it is set like this:
//In .xcconfig file
xconfig_mode = debugMode
Last I created one script trying to fetch and print the value like this:
//In .script file
script_mode=$(/usr/libexec/PlistBuddy -c 'Print custom_mode' "${INFOPLIST_FILE}")
echo "plist value for custom_mode: ${custom_mode}"
When I finished the above steps and run the app, the script is printing but only it is like
"plist value for custom_mode: $(xcconfig_mode)"
It didn't print the real value set by xcconfig file but the variable name. So how can I be able to get the real value set by xcconfig?
Assuming you are running this script in a build phase script here the build settings are available as environment variables when you can use this:
script_mode_var=$(/usr/libexec/PlistBuddy -c 'Print custom_mode' "${INFOPLIST_FILE}")
script_mode=${!script_mode_var}
From man bash:
If the first character of parameter is an exclamation point (!), it
introduces a level of variable indirection. Bash uses the value of the
variable formed from the rest of parameter as the name of the
variable; this variable is then expanded and that value is used in the
rest of the substitution, rather than the value of parameter itself.
An alternative way is to take the value from the info.plist that Xcode has already processed(and replaced the variables with their value). This can be found in the path plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH". So you can modify you script as such:
plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH"
script_mode=$(/usr/libexec/PlistBuddy -c 'Print custom_mode' "${plist}")

Custom Config File Parsing in Bash

I'm creating a bash script for screen management and want to pull variables from a config file formatted like so:
[s=sample1]
FOLDER=folder/right/here
COMMAND=python script.py
[i=irssi]
COMMAND=irssi
BOOT
"FOLDER", "COMMAND", and "BOOT" would be optional. "[x=y]" would be required, where "x" is a single lowercase letter.
I'd like for this sample to be parsed into something like:
NAME[0]="sample1"
SHORT[0]="s"
FOLDER[0]="folder/right/here"
COMMAND[0]="python script.py"
NAME[1]="irssi"
SHORT[1]="i"
BOOT[1]="1"
If you really need to parse ini-styled config files in bash, have a look at this link. Else, as others have pointed out, just place the variables in a file and source it...

Resources