function longrunning() {
const timestamp = process.hrtime(); // returns high-resolution array pair: [seconds, nanoseconds]
// ...
// do something
// ...
const elapsed = (([sec, ns] = process.hrtime(timestamp)) => ((sec + (ns / 1e9)) * 1e3))(); // converts [seconds, nanoseconds] into milliseconds
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain site.crt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export WDHIST=( $(pwd) ) | |
function cd { | |
builtin cd $* | |
if [ $? -eq 0 ]; then | |
WDHIST[${#WDHIST[*]}]=$(pwd) | |
fi | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--#if expr="v('REQUEST_URI') =~ m#^/contact#" --> | |
<!--#set var="pathclass" value="contact" --> | |
<!--#elif expr="v('REQUEST_URI') =~ m#^/work#" --> | |
<!--#set var="pathclass" value="work" --> | |
<!--#elif expr="v('REQUEST_URI') =~ m#^/$#" --> | |
<!--#set var="pathclass" value="about" --> | |
<!--#endif --> | |
<html lang="en-US" class="<!--#echo var="pathclass" -->"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rsync --checksum --human-readable --archive --verbose --compress --partial --progress --rsh=ssh <host>:<remote-path> <local-path> | |
* Note: if <path> ends with /, the specified directory is not included in the copy, just its contents (recursively). I.e., to copy a remote "folder" to a local "folder", without copying the folder itself, include a trailing "/" in the remote path. | |
Options: | |
--checksum: skip based on checksum, not mod-time & size | |
--human-readable: output numbers in a human-readable format | |
--archive: archive mode; same as -rlptgoD (no -H) | |
-r, --recursive: recurse into directories | |
-l, --links: copy symlinks as symlinks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tl;dr: | |
gunzip --to-stdout logfile-*.gz | grep " 404 " | cut -d " " -f 7 | sort | uniq -c | sort --numeric-sort --reverse > unique-404s.txt | |
Starting with a bunch of gzipped log files, like "logfile-*.gz". | |
First, uncompress to stdout: | |
gunzip --to-stdout logfile-*.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create "rescue" partition, do minimal installation, boot (replace ? with root partition device): | |
[Grub console:] | |
> set root=(hd0,gptX) | |
> linux /vmlinuz root=/dev/? | |
> initrd /initrd.img | |
> boot | |
Bring it up to date and install cryptsetup. |
NewerOlder