Skip to content

Instantly share code, notes, and snippets.

@joergeschmann
joergeschmann / shell-copy-logfiles
Created August 6, 2016 08:25
Copy distributed log files into a folder
baseFolder="/tmp/app"
logFilesToCopy=("$baseFolder/auth/log/auth.log" "$baseFolder/jobs/log/jobs.log" "$baseFolder/app.log")
destination="/tmp/logs"
for logFile in ${logFilesToCopy[@]}
do
# logFile -> variable; ## -> greedy front trim; */ -> match everything until the last '/'
filename=${logFile##*/}
@joergeschmann
joergeschmann / autocomplete.html
Last active September 23, 2019 17:33
AngularJS autocomplete directive example
<!DOCTYPE html>
<html ng-app='app'>
<head>
<title>Autocomplete Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Autocomplete Example</h1>
@joergeschmann
joergeschmann / jquery-auth-header
Created March 28, 2014 09:49
Set Authorization header for every jQuery request
/* Check for local storage support */
if(typeof(localStorage) == "undefined") {
alert("no storage!");
}
/* var to encapsulate the logic */
var authController = authController || {};
authController.setAuthHeader = function(value) {
localStorage.setItem("authHeader", value);
@joergeschmann
joergeschmann / shell-sort-text-words
Last active December 25, 2015 02:08
Splitt a text into its words, count the occurrences, sort it by that and save it to a file.
Shell command:
cat text.txt | tr -sc 'A-Za-z' '\n' | sort | uniq -c | sort -nr >> counts.txt
The content of text.txt:
Lorem Ipsum Dolor Sit Amet. Lorem ipsum.
The result in counts.txt:
2 Lorem