Skip to content

Instantly share code, notes, and snippets.

View khan-rizwan's full-sized avatar

Rizwan Khan khan-rizwan

View GitHub Profile
@khan-rizwan
khan-rizwan / nearby-coordinates.sql
Created November 29, 2018 16:57 — forked from statickidz/nearby-coordinates.sql
Ordering with SQL by nearest latitude & longitude coordinates (MySQL & SQLite)
---
METHOD 1
This should roughly sort the items on distance in MySQL, and should work in SQLite.
If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance.
---
SELECT *
FROM table
ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC
@khan-rizwan
khan-rizwan / wsl-go-install.sh
Created July 17, 2018 21:24
Script to install Go 1.8.3 on Linux and WSL (Windows Subsystem for Linux)
#!/bin/bash
set -e
GVERSION="1.8.3"
GFILE="go$GVERSION.linux-amd64.tar.gz"
GOPATH="$HOME/projects/go"
GOROOT="/usr/local/go"
if [ -d $GOROOT ]; then
echo "Installation directories already exist $GOROOT"
@khan-rizwan
khan-rizwan / ubuntudocker.sh
Last active July 17, 2018 14:03 — forked from fredhsu/ubuntudocker.sh
Shell script to install Docker CE on ubuntu and post-install user configuration
#!/bin/bash
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \