Skip to content

Instantly share code, notes, and snippets.

View evansmwendwa's full-sized avatar
🎵
Not stopping

Evans Mwendwa evansmwendwa

🎵
Not stopping
View GitHub Profile

Keybase proof

I hereby claim:

  • I am evansmwendwa on github.
  • I am evansmwendwa (https://keybase.io/evansmwendwa) on keybase.
  • I have a public key ASAaLpKDfAj1xaaNCPtTFX-to8Of8GHExNsVjjTLdnzMKwo

To claim this, I am signing this object:

@evansmwendwa
evansmwendwa / Google-AppScript-SyncJSON.gs
Created June 5, 2017 18:40
Script to sync rest endpoint to Google Spreadsheets
function parseISOString(s) {
var b = s.split(/\D+/);
return new Date(Date.UTC(b[0], --b[1], b[2], b[3], b[4], b[5], b[6]));
}
function pullJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getActiveSheet();
<?php
/*
Plugin Name: php Malicious Code Scanner
Plugin URI: http://www.mikestowe.com/phpmalcode
Description: The php Malicious Code Scanner checks all files for one of the most common malicious code attacks, the eval( base64_decode() ) attack...
Version: 1.3 alpha
Author: Michael Stowe
Author URI: http://www.mikestowe.com
Credits: Based on the idea of Er. Rochak Chauhan (http://www.rochakchauhan.com/), rewritten for use with a cron job
License: GPL-2
@evansmwendwa
evansmwendwa / References.md
Last active May 29, 2018 20:15
Add Random Password Generator

Installing latest git

down vote accepted Use the PPA from the maintainers of git on Ubuntu:

sudo apt-add-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

DEPLOYING DJANGO APPLICATION TO UBUNTU SERVER

KMD CASE - DEPLOYED IN FORGE

Warning! Intermediate experience in setting up Nginx and Python in ubuntu is required to follow this setup

This setup uses Python version 2.7.x and Ubuntu 16 setup with a non root sudo account.

This Tutorial follows the article provided by digital ocean https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04 and the setup is done in a digital ocean droplet provisioned by Laravel forge. Forge's sites feature and SSL feature is used instead of manual nginx server blocks.

Install the Packages from the Ubuntu Repositories

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>Welcome to FarAndOut Studio</title>
<style media="screen">
html {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
<?php
function http_get_file($remote_url, $local_file) {
$fp = fopen($local_file, 'w');
$cp = curl_init($remote_url);
curl_setopt($cp, CURLOPT_FILE, $fp);
$buffer = curl_exec($cp);
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/afriscout.ihub.co.ke/before/*;
server {
listen 80;
listen [::]:80;
server_name afriscout.ihub.co.ke;
return 301 https://$host$request_uri;
}
---
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

Docker installation on Ubuntu

Uninstall old versions

sudo apt-get remove docker docker-engine docker.io

Update the apt package index:

sudo apt-get update