Skip to content

Instantly share code, notes, and snippets.

View alexei's full-sized avatar
Gone Sailing

Alexandru Mărășteanu alexei

Gone Sailing
View GitHub Profile
@alexei
alexei / geo.js
Created May 11, 2018 11:46 — forked from mkhatib/geo.js
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {
@alexei
alexei / XForwardedPort.py
Last active July 6, 2016 14:30 — forked from mattrobenolt/gist:4439597
Django middleware to capture X-Forwarded-Port header
class XForwardedPort(object):
def process_request(self, request):
try:
request.META['SERVER_PORT'] = request.META['HTTP_X_FORWARDED_PORT']
except KeyError:
pass
return None
@alexei
alexei / start-stop-example.sh
Created December 17, 2015 11:37 — forked from alobato/start-stop-example.sh
start-stop-example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar