Mind Mining Medium

Google Sheets: Get Neighborhood from Address or Query

If you need you get the neighborhood based an address or location name, it’s pretty easy using Google App Scripts and the HERE API. You’ll need to supply your own HERE API key. They have a freemium model that is pretty generious (250k transactions per month).

First, in your Google Spreadsheet, create an “Apps Script”. As of 2021, you can do this by going to Extentions > Apps Script. Ths will open a new Apps Script file.

Inside the Apps Script site, rename the project to getNeighborhood and paste the following code inside Code.gs.

const hereAPIKey = '<YOUR_HERE_API_KEY>';

function getNeighborhood(query) {
  query = query.trim();

  if (!query || !query.length) {
    throw new Error('<query> cannot be empty');
  }

  const encodedAddress = encodeURIComponent(query);
  const URL = `https://geocode.search.hereapi.com/v1/geocode?apiKey=${hereAPIKey}&q=${encodedAddress}`;
  const results = UrlFetchApp.fetch(URL);
  const data = JSON.parse(results);
  return data['items'][0]['address']['district'];
}

Be sure to save and click Debug. Confirm permissions once they pop up and you’re set.

Back inside your spreadsheet, you can use the new function like so:

=getNeighborhood("312 W Adams St, Chicago")
=getNeighborhood("Sears Tower, Chicago")
=getNeighborhood(A2)

Source: https://github.com/karbassi/apps-script-getNeighborhood

Build tmux on CentOS 7

If you need to install tmux 2.8 or tmux 2.9 on CentOS 7, here’s the quick way to get it installed.

cd /tmp
sudo yum remove -y tmux
git clone https://github.com/tmux/tmux.git
cd tmux
git checkout 2.9a
sudo yum install -y libevent-devel ncurses-devel automake
sh autogen.sh
./configure && make
sudo make install
cd -
tmux -V

Breakdown

Move to /tmp directory since we don’t really care about where we download the source file.

cd /tmp

Remove previously installed tmux

sudo yum remove -y tmux

Download source from GitHub.

git clone https://github.com/tmux/tmux.git

Move into source directory

cd tmux

Check out current stable version. Change 2.9a to whatever version is most current at the time.

git checkout 2.9a

Install libevent, ncurses, and automake as they are requirements.

sudo yum install -y libevent-devel ncurses-devel automake

Run autogen.sh.

sh autogen.sh

Configure, make, and install.

./configure && make
sudo make install

Go back to previous directory.

cd -2

Check tmux version.

tmux -V

Copy (cp) with progress bar

Many times you’d like to see the progress of a copy but sadly cp doesn’t have that feature.

Many posts online will show bash scripts that pipe cp into grep/awk/etc or use tools like pv. Alas, there is a much more simple way. Use rsync.

rsync -a --progress SOURCE_FOLDER DESTINATION_FOLDER

Throw the --stats flag for some stats after the transfer is done.

rsync -a --stats --progress SOURCE_FOLDER DESTINATION_FOLDER

Apache time sensitive conditions

If you’d like to do time sensitive conditionals on Apache, the following will help you get started. This is useful if you’d like certain content to be displayed based on time.

<!--#config timefmt="%Y%m%d%H%M" -->
<!--#if expr="$DATE_LOCAL < 201303281140" -->
    <!--#include virtual="before.html"-->
<!--#elif expr="$DATE_LOCAL >= 201303281140 && $DATE_LOCAL <= 201303281205"-->
    <!--#include virtual="during.html"-->
<!--#else-->
    <!--#include virtual="after.html"-->
<!--#endif-->

What we do here is set the time format to %Y%m%d%H%M which is year, month, day, hour, minute. For example “201303281140” for March 28th, 2013 at 11:40am.

Then if the current server time is before set time, we display before.html; if the time is during our two times, we display during.html; else we display after.html.

Unroot and Reset the Sprint Galaxy Nexus - Mac

Warning: The following steps WILL format the device. Be sure to do a complete backup before preceeding.

  1. Download the Android SDK.

  2. Install the SDK as instructed.

  3. Follow the instructions on this page from the Android SDK’s “Adding Platforms and Packages

  4. Check and install the “Android SDK Platform-Tools” only.

  5. You should have a directory called android-sdk-mac_x86. Within that, there should be directory called Platform-Tools.

  6. Go as instructed to the “Return To Stock (ODIN TARS & FASTBOOT IMGS)” page. Second post will have the FASTBOOT images. For stock Jelly Bean search for FH05. There is 6 files that need to download.

  7. Place all the downloaded files inside android-sdk-mac_x86/platform-tools/ directory.

  8. Shut down the device, then press and hold Volume Up, Volumn Down, and Power at the same time. This will enter to the bootloader.

  9. Connect the device via USB to the computer.

  10. Open terminal and go into the “platform-tools” directory.

  11. Enter the following lines, one at a time.
    ./fastboot flash boot boot.img
    ./fastboot flash bootloader bootloader.img
    ./fastboot flash recovery recovery.img
    ./fastboot flash system system.img
    ./fastboot flash radio radio-cdma.img
    ./fastboot flash radio radio-lte.img
    ./fastboot -w
    
  12. Enter the following to lock the device also.
    ./fastboot oem lock