Skip to content

Instantly share code, notes, and snippets.

authorEditorAccess.addAuthorCaretListener(new AuthorCaretListener() {
@Override
public void caretMoved(AuthorCaretEvent caretEvent) {
AuthorNode currentNode = caretEvent.getNode();
if (currentNode.getType() != AuthorNode.NODE_TYPE_ELEMENT) {
return;
xquery version "3.1";
import module namespace http = "http://expath.org/ns/http-client";
(: For generating the personal access token to be used in this script, please select "public_repo | Access public repositories". :)
let $git-token := "<your-github-token>"
let $user-name := "<your-github-username>"
let $repo-name := "<your-repo-name>"
let $file-path := "<file=path>"
let $message := "<commit-message>"
let $new-file-content := serialize(<a/>)
/*
This script uses Oxygen operation called JSOperation, see https://www.oxygenxml.com/doc/versions/18.0/ug-editorEclipse/topics/dg-default-author-operations.html.
For generating the personal access token to be used in this script, please select "public_repo | Access public repositories".
This script has to be put in the file ${framework}/commons.js.
In order to add the button for publishing to github, add the following code to any CSS file that is associated within the framework with the edited XML file:
rdf|RDF:before {
content: oxy_button(action, oxy_action(name, "Publish to github", operation, "ro.sync.ecss.extensions.commons.operations.JSOperation", arg-script, "function doOperation(){publishToGihub();}"))
}
*/
@claudius108
claudius108 / git.md
Last active May 10, 2023 16:59 — forked from stephenhardy/git-clearHistory
Steps to clear out the history of a git/github repository

RECREATE A REPO WITH ONLY THE CONTENT

Remove the history

rm -rf .git

recreate the repo from the current content only

git init git add . git commit -m "Initial commit"

push to the github remote repos ensuring you overwrite history

Files that are in both Dir1 and Dir2:
find "$Dir1/" "$Dir2/" -printf '%P\n' | sort | uniq -d
Files that are in Dir1 but not in Dir2:
find "$Dir1/" "$Dir2/" "$Dir2/" -printf '%P\n' | sort | uniq -u
@claudius108
claudius108 / add-index-configuration-file.xql
Last active November 27, 2020 08:14
local:add-index-configuration-file()
declare function local:add-index-configuration-file($collection-path as xs:string) {
let $index-collection-path := $system-config-collection-path || $collection-path
return (
if (not(xmldb:collection-available($index-collection-path)))
then local:create-collections-recursively($system-config-collection-path, tokenize($collection-path, "/"))
else ()
,
xmldb:store-files-from-pattern($index-collection-path, $dir, "modules/indexes" || $collection-path || "/*.xconf")
,
@claudius108
claudius108 / create-collections-recursively.xql
Created November 27, 2020 08:14
local:create-collections-recursively()
declare function local:create-collections-recursively($target-collection-uri as xs:string, $new-collection-path-steps as xs:string*) as xs:string* {
if (exists($new-collection-path-steps))
then
let $new-collection-name := $new-collection-path-steps[1]
let $new-collection-uri := $target-collection-uri || "/" || $new-collection-name
return (
if (not(xmldb:collection-available($new-collection-uri)))
then xmldb:create-collection($target-collection-uri, $new-collection-name)
else ()
@claudius108
claudius108 / find-string-in-files.sh
Last active December 21, 2020 15:12
find-string-in-files
find . -name "*" -print0 | xargs -0 grep -l "22"
@claudius108
claudius108 / sed.md
Last active June 8, 2024 06:16
Delete line with sed

Delete recursively line containing string

find ./ -name "*.xml" -exec sed -i '/<p> <\/p>/d' {} \;

Find recursively string in files

find . -name "*" -print0 | xargs -0 grep -l "string"

Delete recursively one line following the line containing string, exclusive

find ./ -name "A*.xml" -exec sed -i '/string/{n;d}' {} \;

Delete recursively five lines following the line containing string, inclusive

Find recursively files containing multiline string

grep -Pazor --include="A*.xml" 'string.*\n.*string' .

Find recursively files containing string

grep -ril --include="A*.xml" "string" .

Find recursively files NOT containing string

grep -riL --include="A*.xml" "string" .

Filter twice some files and replace string