-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.notes
56 lines (47 loc) · 2.64 KB
/
.notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
### Search-replace magic examples
$ perl -e 's/str1/str2/g;' -pi $(find . -type f -name "*cpp" -or -name "*.h")
$ perl -i -pe 'BEGIN{undef $/;} s/(install.*?_version\.h.*?DESTINATION) (\${(.*?)})/\1 foo' CMakeLists.txt # multi-line replace, non-greedy
$ perl -e 's/str1/str2/g;' -pi.save $(find . -type f -name "*py") # create backup files
$ perl -e 's/\#ifndef (\w+_H)/#ifndef KGRAPHVIZ_\1/g;' -pi $(find . -type f -name "*.h") # add namespace to include guards
$ perl -e 's/Analyzer::Internal/Valgrind::Internal/g;' -pi $(find . -type f -regextype posix-egrep -regex ".+cpp|.+h|.+ui")
$ perl -i -0pe '~s/\n+$/\n/' $(find -iname "*cpp") # remove extra newlines at EOF
# Perl multi-line replace (example: remove impl and decl of method)
$ perl -0777 -pe '$pattern = qq(bool (\\w+)\Q::checkData(int row, int feldIndex, const QVariant &wert)
{
if (row == -99) {
if (wert.toString() == "???") {
QMessageBoxExt::critical(nullptr, QObject::tr(gltext::error), tr("Wert ??? nicht erlaubt"), QMessageBox::Ok);
return false;
}
}
return true;
}
\E); $pattern =~ s/\n/\R/g; print $pattern; s/$pattern//igs' mAnrede.cpp
for i in *; do perl -0777 -i -pe '$pattern = qq(\\s+\Qbool checkData(int row, int feldIndex, const QVariant &wert);\E); $pattern =~ s/\n/\R/g; s/$pattern//igs' $i
# fix automoc warnings (brute-force method)
Pipe compile/autmoc output to file 'a'. Then:
$ grep "No output generated" a | grep -Po1 '(\w+)\.cpp' | sed 's/\.cpp//' > b
$ for i in $(cat b); do perl -e "s#\"$i\.moc\"#\"moc_$i\.cpp\"#g;" -pi $(find . -type f -name "*.cpp"); done
### Qt compile
# normal
$ time (../../src/qt/configure -shared -debug -developer-build -nomake demos -nomake examples -fast -no-phonon -no-qt3support -opensource -confirm-license && make sub-src)
# extended
$ time (../../src/qt/configure -shared -debug -developer-build -nomake demos -nomake examples -webkit -xmlpatterns -scripttools -fast -plugin-sql-mysql -plugin-sql-psql -plugin-sql-sqlite -exceptions -qt3support -developer-build -opensource -confirm-license && make && make install)
### Aptitude
Searches and pattern matching in Aptitude is different:
You basically want to use a '~' character to start the pattern
- searching for a pattern in the name of the package (~n<regex>)
- or in the description (~d<regex>) and so on.
Example: aptitude -s install "~n.*qc-usb.*"
### Git magic
# Fix committer emails for recent (unpushed) commits
git filter-branch --env-filter '
if [ "$GIT_AUTHOR_EMAIL" = "kfunk@kde.org" ];
then
export GIT_AUTHOR_EMAIL="kevin.funk@kdab.com";
fi
if [ "$GIT_COMMITTER_EMAIL" = "kfunk@kde.org" ];
then
export GIT_COMMITTER_EMAIL="kevin.funk@kdab.com";
fi
' HEAD~15..HEAD