I hereby claim:
- I am f-steff on github.
- I am fsteff (https://keybase.io/fsteff) on keybase.
- I have a public key ASDjVUweLva7Q1ChOFIyIM6oVz9iDJ5obsZZNleUt2mgQAo
To claim this, I am signing this object:
| #!/bin/bash | |
| # fsteff 2019 | |
| # Workaround for bash not properly supporting export of environment array variables. | |
| # When using Jenkins 'Inject environment variables' plugin, array variables ends up in a strange state, | |
| # where they are listed as exported variables, but are not actual shell variables. | |
| # Checking using `env` or `printenv` shows injected array variables unrolled (ie not as arrays) | |
| # Checking using `declare -p`, `declare -xp` and `set` does not show injected array variables - but normal array variable are shown as arrays. | |
| # The workaround below loops through the output of `printenv` and sets each injected variable it finds. | |
| # NOTE: This must be run in the 'Execute Shell' where the variables are needed. | |
| # NOTE2: Using as a script file, requires that it's executed as `. ./FixInjectedArraysInBash.sh` or `source ./FixInjectedArraysInBash.sh` |
| :: === Main code: | |
| :: My answer to https://stackoverflow.com/questions/17546016/how-can-you-zip-or-unzip-from-the-script-using-only-windows-built-in-capabiliti/58013665#58013665 | |
| call :ZipUp "C:\Some\Path" "C:\Archive.zip" | |
| :: === SubRoutines: | |
| :ZipUp | |
| ::Arguments: Source_folder, destination_zip |
| #!/bin/bash | |
| echo "Multi line comments in Bash" | |
| : ' | |
| blah blah | |
| blah blah | |
| blah blah | |
| blah blah | |
| blah blah | |
| # ' | |
| echo "All done done!" |
| Private Sub save_CSV() | |
| ' Written by Flemming Steffensen, 1997 | |
| ' The CSV ("Comma Separated Values") File Format: (Simple as it is, Microsoft can not follow the rules!) | |
| ' * Each record is one line - Line separator may be LF (0x0A) or CRLF (0x0D0A), a line seperator may also be embedded in the data (making a record more than one line but still acceptable). | |
| ' * Fields are separated with commas. - Duh. | |
| ' * Leading and trailing whitespace is ignored - Unless the field is delimited with double-quotes in that case the whitespace is preserved. | |
| ' * Embedded commas - Field must be delimited with double-quotes. | |
| ' * Embedded double-quotes - Embedded double-quote characters must be doubled, and the field must be delimited with double-quotes. | |
| ' * Embedded line-breaks - Fields must be surounded by double-quotes. | |
| ' * Always Delimiting - Fields may always be delimited with double quotes, the delimiters will be parsed and discarded by the reading applications. |
| For folks who want Chrome to always restore windows to their original spaces, you can set that by running this command in a terminal window (for Canary, use `com.google.Chrome.canary`): | |
| defaults write com.google.Chrome NSWindowRestoresWorkspaceAtLaunch -bool YES | |
| To go back to the default behavior, run: | |
| defaults delete com.google.Chrome NSWindowRestoresWorkspaceAtLaunch | |
| This should work for any Mac app, not just Chrome. |
| List of Online Tools | |
| ==================== | |
| https://www.shellcheck.net/ | |
| Finds bugs in shell-scrips - not 100% perfect, but comes with very usefull suggestions. | |
| #!/bin/bash | |
| # GOTO for bash, https://stackoverflow.com/questions/9639103/is-there-a-goto-statement-in-bash/52872489#52872489 | |
| # Based upon https://stackoverflow.com/a/31269848/5353461 | |
| function goto | |
| { | |
| local label=$1 | |
| cmd=$(sed -En "/^[[:space:]]*#[[:space:]]*$label:[[:space:]]*#/{:a;n;p;ba};" "$0") | |
| eval "$cmd" | |
| exit |
I hereby claim:
To claim this, I am signing this object:
| # DownloadFtpFolder.ps1 created by f-steff, Sept.12 2019. | |
| # This is a modified version of DownloadFtpDirectory() by Martin Prikryl. | |
| # usage: DownloadFtpFolder.ps1 SourceFolder Destination folder [UrlPort Username Password] | |
| function EnsureTargetDirectory ($localPath) | |
| { | |
| # Ensure to return a full qualified path. | |
| # Will create the folder(s) if needed. | |
| try | |
| { |
| // Created by f-steff 2019. Use and abuse as you wish. | |
| @Grab(group='commons-net', module='commons-net', version='2.0') | |
| import org.apache.commons.net.ftp.FTPClient | |
| import org.apache.commons.net.ftp.FTPFile | |
| //def path="pub/" | |
| println("Fetching reverse sorted list of ftp folders from $path"); | |
| FTPClient ftpClient = new FTPClient() | |
| ftpClient.connect "arnold.c64.org",21 |