jq is useful to slice, filter, map and transform structured json data.
brew install jq
#!/usr/bin/env bash | |
# This script will download a file from a directory in your Dropbox account. | |
# You will need to create a Dropbox App with this link: https://www.dropbox.com/developers/apps/create | |
# then get an Access Token for it. Once you have the token you can add it to the script. | |
# The file will be downloaded to your current directory and will overwrite any existing file with the same name. | |
if (($#<2)) | |
then echo "Error! Usage: $(basename $0) <dropbox_dir> <dropboxfile>" && exit 1 | |
fi |
#!/usr/bin/env python | |
import SimpleHTTPServer | |
class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def end_headers(self): | |
self.send_my_headers() | |
SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self) | |
def send_my_headers(self): | |
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") |
#!/bin/bash | |
# Validates user input for a single valid email address | |
echo -n "Please enter your email address: " | |
read -r | |
# use regex to find valid email address formats and store in new variable | |
userinput=$(echo "$REPLY" | grep -Eo "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b") | |
# check for no results from grep | |
if [[ -z "$userinput" ]] | |
then |
#!/bin/bash | |
echo "The first method uses the TMOUT environment variable." | |
TMOUT=15 | |
echo -n "You have 15 seconds to enter your name: " | |
read name | |
if [[ $name != "" ]] | |
then echo You entered: $name | |
else echo; echo "Nothing entered in time allowed." | |
fi | |
echo "Let's try again. This time using the -t option for read." |
vi
has multiple modes, and it starts in command mode, not editing mode.In command mode, almost every key on the keyboard is mapped to run a specific command or movement, while other keys reference objects.
i
to get into insert mode, which allows you to edit the documentDelete
and Backspace
keys.Esc
to return to command mode.:wq
then press Enter
. Alternately, if you want to discard your changes and quit, while in command mode type :q!
then press Enter
.The
:
puts you inex
mode (some people call it "last line mode") which allows you to runex
commands asvi
was an extension to the olderex
editor. Thew
command writes the changes you made to the disk. (You can use the:w
alone to save changes while you are working and keep working.) Theq
command quits the
I hereby claim:
To claim this, I am signing this object: