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/sh | |
| # Input file | |
| FILE=/tmp/test.txt | |
| # How many seconds before file is deemed "older" | |
| OLDTIME=120 | |
| # Get current and file times | |
| CURTIME=$(date +%s) | |
| FILETIME=$(stat $FILE -c %Y) | |
| TIMEDIFF=$(expr $CURTIME - $FILETIME) |
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 | |
| function try() | |
| { | |
| [[ $- = *e* ]]; SAVED_OPT_E=$? | |
| set +e | |
| } | |
| function throw() | |
| { |
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 | |
| DIR="${BASH_SOURCE%/*}" | |
| if [[ ! -d "$DIR" ]]; then DIR="$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
| # Loads named arguments for script (ie. ./script.sh --some-arg some_arg_value) | |
| # Supports "--" as prefix. If no value is supplied to an entry, then | |
| # it defaults to `true` as the value. | |
| # This script can be used in other scripts by referance: `. ./load_args.sh`. | |
| while [ $# -gt 0 ]; do | |
| if [[ $1 == "--"* ]] | |
| then # Parse command/option. | |
| key="${1/--/}" | |
| val=$2 | |
| if [[ $key == *"="* ]]; then # Handle args with equals sign. |
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
| import { Seq } from 'immutable'; | |
| type RequiredLiteralKeys<T> = { | |
| [K in keyof T]-?: string extends K | |
| ? never | |
| : number extends K | |
| ? never | |
| : {} extends Pick<T, K> | |
| ? never | |
| : K; |
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
| import { Map, List, Set, Seq, fromJS } from 'immutable'; | |
| // keyPaths(val: any, root: Seq) | |
| // - Deeply maps iterable keypaths. | |
| const keyPaths = (val, root = new Seq()) => { | |
| if(typeof val !== 'object') | |
| return [root]; | |
| return new Seq(val).reduce((curr, value, key) => | |
| curr.concat(keyPaths(value, root.concat(key))), new Seq()); | |
| }; |