Skip to content

Instantly share code, notes, and snippets.

@claudius108
claudius108 / git.md
Last active September 29, 2023 14:08
GIT

Filter out from the Git history all the deleted files

git log --diff-filter=D --summary > deleted-files.txt

Checkout a file that was deleted with a certain commit

git checkout <commit-id>~1 <file/path>

Get the subjects and bodies for all the commits

git --no-pager log --stat --format="===%n%s%-b" | sed '/^$/d' &gt; ../commits-log.txt

@claudius108
claudius108 / firefox.md
Created January 12, 2023 06:45
Varia about Firefox

Download PDF-s for viewing in tmp folder

browser.download.start_downloads_in_tmp_dir

@claudius108
claudius108 / linearize-pdf-with-gs.sh
Created December 20, 2022 13:15
Linearize PDF file with GhostScript
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
@claudius108
claudius108 / xmlint.md
Last active March 7, 2023 14:43
xmlint commands

check if xml files are well formed

find ./ -name "*.xml" -exec xmllint --noout {} \;

format files in place

find . -name "*.xml" -type f -exec xmllint --encode utf8 --output '{}' --format --noblanks '{}' \;

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

@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

@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 / 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 / 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")
,
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