Under construction…
Books
• You Don’t Know JS Yet is a good reference for advanced JavaScript development.
Command Line
- Compressing a file.
$ mv file.txt file.txt.old ; touch file.txt ; gzip -9 file.txt.old - Delete all files in the current directory
$ rm -vf ./* or $ find . -type f -delete
- Find a string within files.
$ grep -r "STRING-TO-FIND" --include "." > result.txt
- Find all files matching subdirectory and filename.
$ find . -path "**/directory/file.txt"
- Find all my running processes on server.
$ ps aux | grep ‘USERNAME’
- Find the directories with name.
$ ls -d ** | grep 'STRING-IN-DIR-NAME'
- List all files that have changed in the last 30 minutes.
$ find . -type f -mmin -30
- Watch changes to a file.
$ tail -f file.txt
- Find all git repositories in the current directory tree.
$ find ./ -type d -name ".git"
- Run git pull over all subdirectories:
$ for i in */.git; do ( echo $i; cd $i/..; git pull; ); done
- Find commits in a branch:
$ git cherry -v main
- Don’t use
SELECT *
in queries. - Find all tables in a database.
SELECT tbl_name
FROM sqlite_master
WHERE type = 'table'
ORDER BY tbl_name - Show all tables and indices in a database.
SELECT * FROM sqlite_master
- Use
SELECT DISTINCT
where it makes sense.
Debugging
- If the webpage isn’t showing what you think it should – refresh.
Regular Expressions
- Helpful links for developing Regular Expressions: Regexr, Regex101, Debuggex.
Snipit
- Change HTML into plain old boring regular text.
function htmlToPlainText(html){
//remove code breaks and tabs
html = html.replace(/\n/g, ""); // Carriage return chars
html = html.replace(/\t/g, ""); // Tab chars
//keep html breaks and tabs
html = html.replace(/<\/ol>/g, "\n\n"); //end of list
html = html.replace(/<ol>/g, "\n\n"); // start of list to match what comes out of PATH
html = html.replace(/<\/ul>/g, "\n\n"); //end of list
html = html.replace(/<ul>/g, "\n\n"); // start of list to match what comes out of PATH
html = html.replace(/<\/li>/g, "\n"); // after each list item
html = html.replace(/<\/p>/g, "\n\n") // end of paragraph
html = html.replace(/<\/td>/g, "\t"); // tab
html = html.replace(/<\/table>/g, "\n"); // after a table
html = html.replace(/<\/tr>/g, "\n"); // after a table row
html = html.replace(/<\/div>/g, "\n"); // end of new div
html = html.replace(/<\/h>/g, "\n\n"); // end of header
html = html.replace(/<br>/g, "\n"); // break
html = html.replace(/<br( )*\/>/g, "\n"); //break
return html.replace(/<[^>]+>/g, ""); //pull out any other HTML tags
//return html;
}