Skip to content

Instantly share code, notes, and snippets.

View avantassel's full-sized avatar
💯

Andrew Van Tassel avantassel

💯
View GitHub Profile
@avantassel
avantassel / MNMP.sh
Created July 10, 2013 22:49 — forked from camshaft/MNMP.sh
#!/bin/bash
# vars
PHP_VERSION="5.3.6"
NGINX_VERSION="1.0.4"
MONGO_VERSION="1.8.1"
MEMCACHED_VERSION="1.4.5"
DIRECTORY=$(cd `dirname $0` && pwd)
PHP_DIR=$DIRECTORY/lib/php/$PHP_VERSION/
@avantassel
avantassel / cookies
Created August 5, 2013 20:34
get, set, delete cookies
(function($){
if(typeof utils == 'undefined'){
window.utils={};
}
window.utils = $.extend({}, utils, {
CreateCookie: function(name, value, days){
if (days) {
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
function map() {
emit(1, // Or put a GROUP BY key here
{sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count:1,
diff: 0, // M2,n: sum((val-mean)^2)
});
@avantassel
avantassel / gist:8010032
Created December 17, 2013 18:24
shell git branch to prompt
#found this somewhere long ago
#add to your ~/.profile
#colors
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
@avantassel
avantassel / maxmind_update.sh
Created December 30, 2013 22:23
Update the GeoLiteCity dat from maxmind
#!/bin/bash
dir="/var/www/geoip";
# change to dir
cd ${dir}
#download the dat file from maxmind
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
#unzip and overwrite the .dat file
@avantassel
avantassel / csv-json.php
Last active August 29, 2015 13:57
Download CSV and display in JSON
<?php
/*
* @author Andrew Van Tassel
* @email andrew@andrewvantassel.com
* @notes Create a data directory, Add tac param to start from end of file
* @todo Add paging and offset param
*/
$_GET['limit']=isset($_GET['limit']) && is_numeric($_GET['limit'])?(int)$_GET['limit']:50;
function getFieldKeys($output){
<!DOCTYPE html>
<html>
<!-- ZevRoss Spatial Analysis, www.zevross.com -->
<!-- A note: if you're not seeing the elements in the custom
infowindow look at the cartodb dashboard and make sure they're
turned on
-->
@avantassel
avantassel / datasources.json
Created October 20, 2015 03:21
What 3 Words Strongloop Datasource
"w3w": {
"name": "w3w",
"connector": "rest",
"operations": [
{
"template": {
"method": "GET",
"url": "http://api.what3words.com/position/",
"headers": {
"accepts": "application/json",
@avantassel
avantassel / datasources.json
Created October 20, 2015 03:22
Google Geolocation Strongloop Datasource
"geo": {
"name": "geo",
"connector": "rest",
"operations": [
{
"template": {
"method": "GET",
"url": "http://maps.googleapis.com/maps/api/geocode/{format=json}",
"headers": {
"accepts": "application/json",
@avantassel
avantassel / purgePath
Created June 14, 2016 18:55 — forked from AD7six/purgePath
Script to ensure a folder used for caching always has x% free space. Generated with new_script http://linuxcommand.org/script_library.php
#!/bin/bash
################################################################################
#
# Delete least used files
#
################################################################################
PROGNAME=${0##*/}
PROGDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
VERSION="0.1"