From ac97ae2802f239fc4ae86ca937740d6142672271 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Mon, 26 Jul 2021 10:47:06 -0400 Subject: [PATCH] New Posts --- content/blog/antenna-basics.md | 17 ++++++++++ content/blog/parallel-scp.md | 61 ++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 content/blog/antenna-basics.md create mode 100644 content/blog/parallel-scp.md diff --git a/content/blog/antenna-basics.md b/content/blog/antenna-basics.md new file mode 100644 index 0000000..0841381 --- /dev/null +++ b/content/blog/antenna-basics.md @@ -0,0 +1,17 @@ +--- +title: "Antenna Basics" +date: 2021-07-25T10:43:11-04:00 +draft: false +tags: [] +math: false +--- +When a radio wave hits an antenna, the electrical component of the wave induces a difference of potential in the conductor which gives rise to an electric current. This is called electromotive force. The current induced is normally small, therefore, we usually design antennas to be as efficient as possible. + +Ways to increase efficiency: +- Ensure that the impedance of the antenna matches what it's hooked up to. +- Cap the ends of the antenna with an insulator +- If there is a power line nearby, run the antenna at a right angle to that wire to decrease interference. +- Make the antenna resonant at the frequency you're interested in. You can do this by adjusting the length of the wire, inductance, capacitance. +- Design the antenna so that it focuses the energy from the direction you care about, as opposed to listening equally in all directions. +- Similarly, raise the antenna higher off the ground so that more of it's beam pattern reaches the horizon. + diff --git a/content/blog/parallel-scp.md b/content/blog/parallel-scp.md new file mode 100644 index 0000000..91a7729 --- /dev/null +++ b/content/blog/parallel-scp.md @@ -0,0 +1,61 @@ +--- +title: "Parallel SCP with LFTP" +date: 2021-07-25T10:38:43-04:00 +draft: false +tags: [] +math: false +--- +Segmented file transfer allows you to split up a file into multiple chunks and download them in parallel. There is a program written for Linux called LFTP which can accomplish this task and supports FTP, HTTP, SFTP, BitTorrent, among others. The syntax is a little funky, so I wrote a wrapper I call `pget` which allows for segmented file transfers using SCP. + +Usage: +```bash +pget [user@host] [file] [segments?] +``` +where `segments?` is optional. + +Example: +```bash +pget user@127.0.0.1 Documents/todo.txt 3 +``` + + +The full script: +```bash +#!/bin/sh +# set -xv + +show_usage() { + echo "Usage: pget [user@host] [file] [segments?]" + echo "Example: pget user@127.0.0.1 Documents/todo.txt 3" + echo "Currently only supports sftp. Segments value are optional." + exit 1 +} + +contains_help_flag() { + if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + return 0 + fi + return 1 +} + +if [ "$#" -lt 2 ] || + [ "$#" -gt 3 ] || + contains_help_flag "$1" || + contains_help_flag "$2" || + contains_help_flag "$3" ; then + show_usage +fi + +REMOTE_HOST="$1" +FILE_LOCATION="$2" + +if [ "$#" -eq 3 ]; then + NUM_SEGMENTS="$3" +else + NUM_SEGMENTS="1" +fi + +LFTP_COMMAND="pget -n $NUM_SEGMENTS $FILE_LOCATION;bye" +lftp -e "$LFTP_COMMAND" sftp://"$REMOTE_HOST" +``` +