MooTools build hash in 1.2.4.4 - mootools

We are trying to upgrade our MooTools installation from 1.2.4 to 1.2.6. The original developer included a "more" file with optional plugins, but because it is compressed we can't tell what was included in that file. I'd rather not hunt and pick through the code.
I noticed the compressed more file has a build hash in the header (6f6057dc645fdb7547689183b2311063bd653ddf). The 1.4 builder located here will let you just append that hash to the url and create a build. It doesn't seem the 1.2 version supports that functionality.
Is there an easy way to determine from the hash or the compressed file what plugins are included in this 1.2 build?

AFAIK there's no way to get the list of plugins directly from the build hash. But if you have access to a UNIX shell, save the following shell script as find_plugins.sh:
#!/bin/sh
for PLUGIN in \
More Lang Log Class.Refactor Class.Binds Class.Occlude Chain.Wait \
Array.Extras Date Date.Extras Hash.Extras String.Extras \
String.QueryString URI URI.Relative Element.Forms Elements.From \
Element.Delegation Element.Measure Element.Pin Element.Position \
Element.Shortcuts Form.Request Form.Request.Append Form.Validator \
Form.Validator.Inline Form.Validator.Extras OverText Fx.Elements \
Fx.Accordion Fx.Move Fx.Reveal Fx.Scroll Fx.Slide Fx.SmoothScroll \
Fx.Sort Drag Drag.Move Slider Sortables Request.JSONP Request.Queue \
Request.Periodical Assets Color Group Hash.Cookie IframeShim HtmlTable \
HtmlTable.Zebra HtmlTable.Sort HtmlTable.Select Keyboard Keyboard.Extras \
Mask Scroller Tips Spinner Date.English.US Form.Validator.English \
Date.Catalan Date.Czech Date.Danish Date.Dutch Date.English.GB \
Date.Estonian Date.German Date.German.CH Date.French Date.Italian \
Date.Norwegian Date.Polish Date.Portuguese.BR Date.Russian Date.Spanish \
Date.Swedish Date.Ukrainian Form.Validator.Arabic Form.Validator.Catalan \
Form.Validator.Czech Form.Validator.Chinese Form.Validator.Dutch \
Form.Validator.Estonian Form.Validator.German Form.Validator.German.CH \
Form.Validator.French Form.Validator.Italian Form.Validator.Norwegian \
Form.Validator.Polish Form.Validator.Portuguese \
Form.Validator.Portuguese.BR Form.Validator.Russian \
Form.Validator.Spanish Form.Validator.Swedish Form.Validator.Ukrainian
do
grep -q -F $PLUGIN $1 && echo $PLUGIN
done
Then run it like this passing the filename of your MooTools More file as first argument:
sh find_plugins.sh mootools-more.js
It will print out a list of all plugin names found in the JS code. That should get you started.

Related

Can you separate distinct JSON attributes into two files using jq?

I am following this tutorial from Vault about creating your own certificate authority. I'd like to separate the response (change the output to API call using cURL to see the response) into two distinct files, one file possessing the certificate and issuing_ca attributes, the other file containing the private_key. The tutorial is using jq to parse JSON objects, but my unfamiliarity with jq isn't helpful here, and most searches are returning info on how to merge JSON using jq.
I've tried running something like
vault write -format=json pki_int/issue/example-dot-com \
common_name="test.example.com" \
ttl="24h" \
format=pem \
jq -r '.data.certificate, .data.issuing_ca > test.cert.pem \
jq -r '.data.private_key' > test.key.pem
or
vault write -format=json pki_int/issue/example-dot-com \
common_name="test.example.com" \
ttl="24h" \
format=pem \
| jq -r '.data.certificate, .data.issuing_ca > test.cert.pem \
| jq -r '.data.private_key' > test.key.pem
but no dice.
It is not an issue with jq invocation, but the way the output files get written. Per your usage indicated, after writing the file test.cert.pem, the contents over the read end of the pipe (JSON output) is no longer available to extract the private_key contents.
To duplicate the contents over at the write end of pipe, use tee along with process substitution. The following should work on bash/zsh or ksh93 and not on POSIX bourne shell sh
vault write -format=json pki_int/issue/example-dot-com \
common_name="test.example.com" \
ttl="24h" \
format=pem \
| tee >( jq -r '.data.certificate, .data.issuing_ca' > test.cert.pem) \
>(jq -r '.data.private_key' > test.key.pem) \
>/dev/null
See this in action
jq -n '{data:{certificate: "foo", issuing_ca: "bar", private_key: "zoo"}}' \
| tee >( jq -r '.data.certificate, .data.issuing_ca' > test.cert.pem) \
>(jq -r '.data.private_key' > test.key.pem) \
>/dev/null
and now observe the contents of both the files.
You could abuse jq's ability to write to standard error (version 1.6 or later) separately from standard output.
vault write -format=json pki_int/issue/example-dot-com \
common_name="test.example.com" \
ttl="24h" \
format=pem \
| jq -r '.data as $f | ($f.private_key | stderr) | ($f.certificate, $f.issuing_ca)' > test.cert.pem 2> test.key.pem
There's a general technique for this type of problem that is worth mentioning
because it has minimal prerequisites (just jq and awk), and because
it scales well with the number of files. Furthermore it is quite efficient in that only one invocation each of jq and awk is needed. The idea is to setup a pipeline of the form: jq ... | awk ...
There are many variants
of the technique but in the present case, the following would suffice:
jq -rc '
.data
| "test.cert.pem",
"\t\(.certificate)",
"\t\(.issuing_ca)",
"test.key.pem",
"\t\(.private_key)"
' | awk -F\\t 'NF == 1 {fn=$1; next} {print $2 > fn}'
Notice that this works even if the items of interest are strings with embedded tabs.

Create Azure EventHub via CLI with Capture

Scenario: I am putting together a repeatable script that creates, among other things, an Azure EventHub. My code looks like:
az eventhubs eventhub create \
--name [name] \
--namespace-name [namespace] \
--resource-group [group] \
--status Active \
--enable-capture true \
--archive-name-format "{Namespace}/{EventHub}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}/{PartitionId}" \
--storage-account [account] \
--blob-container [blob] \
--capture-interval 300 \
--partition-count 10 \
--skip-empty-archives true
If I run the code as written, I get a "Required property 'name' not found in JSON. Path 'properties.captureDescription.destination', line 1, position 527."
However, if I remove the --enable-capture true parameter, the EventHub is created, albeit with Capture not enabled. If I enable Capture, none of the capture-related parameters other than the interval are set.
Is there a typo in there that I'm not seeing?
Try providing the --destination-name.
az eventhubs eventhub create --name
--namespace-name
--resource-group
[--archive-name-format]
[--blob-container]
[--capture-interval]
[--capture-size-limit]
[--destination-name]
[--enable-capture {false, true}]
[--message-retention]
[--partition-count]
[--skip-empty-archives {false, true}]
[--status {Active, Disabled, SendDisabled}]
[--storage-account]

Github api not parsing multi line shell variables

I've got a text param (from jenkins job dsl plugin) in jenkins configuration which allows you to enter a multi line comment. I'm using that variable for the body value when posting a release to a github repository from a shell script. I'm getting this error that says problem parsing json and I can't find a workaround. I'll try to give you an example below. Please help.
PERSONAL_ACCESS_TOKEN="random"
TAG_NAME="12.0.0"
VERSION_BUMP="major"
MIGRATION_DOCUMENT="This is first line
This is second line"
curl -i \
-H "Authorization: token ${PERSONAL_ACCESS_TOKEN}" \
-d '{"tag_name": "'"${TAG_NAME}"'", "name": "'"${VERSION_BUMP}"'", \
"body": "'"${MIGRATION_DOCUMENT}"'"}' \
https://github.deere.com/api/v3/repos/randomOrg/testRepo/releases
This
{ "a": "b
c" }
is invalid JSON because a string must not contain control characters such as newlines.
If you have a string containing newlines, you can convert them to \n using shell parameter expansion:
$ var='a
b'
$ echo "$var"
a
b
$ echo "${var//$'\n'/'\n'}"
a\nb
So, to feed your string into your JSON object, use
"body": "'"${MIGRATION_DOCUMENT//$'\n'/'\n'}"'"
at the end of your JSON object.
Also, if you use line continuation in single quotes such as
var='abc \
def'
then the backslash and the linebreak are literal:
$ echo "$var"
abc \
def
Don't use line continuation like that in single quoted strings.
All in all:
curl -i \
-H "Authorization: token ${PERSONAL_ACCESS_TOKEN}" \
-d '{"tag_name": "'"${TAG_NAME}"'", "name": "'"${VERSION_BUMP}"'", "body": "'"${MIGRATION_DOCUMENT//$'\n'/'\n'}"'"}' \
https://github.deere.com/api/v3/repos/randomOrg/testRepo/releases
If you really want to, you can still use line continuation, but it has to be in a double quoted context:
curl -i \
-H "Authorization: token ${PERSONAL_ACCESS_TOKEN}" \
-d '{"tag_name": "'"${TAG_NAME}"'", "name": "'"${VERSION_BUMP}"'", '"\
"'"body": "'"${MIGRATION_DOCUMENT//$'\n'/'\n'}"'"}' \
https://github.deere.com/api/v3/repos/randomOrg/testRepo/releases
As a side note, you shouldn't use all uppercase names for variables; those are reserved for environment variables, see the POSIX spec (fourth paragraph).

How to insert variable in fswatch regex?

I'm trying to use a variable to identify mxf or mov file extensions. The following works where I explicitly name the file extensions with a regular expression.
${FSWATCH_PATH} -0 \
-e ".*" --include ".*\.[ mxf|mov ]" \
--event Updated --event Renamed --event MovedTo -l $LATENCY \
$LOCAL_WATCHFOLDER_PATH \
| while read -d "" event
do
<code here>
done
How can I use a variable for the file extensions, where the variable name is FileTriggerExtensions? The code below doesn't work:
FileTriggerExtensions=mov|mxf
${FSWATCH_PATH} -0 \
-e ".*" --include ".*\.[ $FileTriggerExtensions ]" \
--event Updated --event Renamed --event MovedTo -l $LATENCY \
$LOCAL_WATCHFOLDER_PATH \
| while read -d "" event
do
done
I guess you use Bash or a similar shell?
FileTriggerExtensions=mov|mxf
-bash: mxf: command not found
Use quotes or escape the pipe symbol.

what are flags in mysql?

I just wanna ask, what are those things called as "flags" in mysql ?
What are they, kindly explain and how they are used.
mysql flags are used by the compiler and set the enviroment you wish to work in.
There's flags such as:
'--with-archive-storage-engine'
wgich does what it states, it would start mysql process but also start the system in archive able content mode
Some more examples:
'--prefix=/usr/local/mysql' \
'--disable-dependency-tracking' \
'--enable-assembler' \
'--localstatedir=/usr/local/mysql/data' \
'--libexecdir=/usr/local/mysql/bin' \
'--libdir=/usr/local/mysql/lib' \
'--enable-local-infile' \
'--enable-shared' \
'--enable-thread-safe-client' \
'--with-archive-storage-engine' \
'--with-big-tables' \
'--with-comment=MySQL Community Server (GPL)' \
'--with-extra-charsets=complex' \
'--with-innodb' \
'--with-mysqld-ldflags=-all-static' \
'--with-readline' \
'--with-server-suffix=-standard' \
'--with-unix-socket-path=/tmp/mysql.sock' \
'--with-zlib-dir=bundled' \
'--without-debug' \
'--without-docs' \
'--without-man'