Skip to content

Instantly share code, notes, and snippets.

View aarondfrancis's full-sized avatar

Aaron Francis aarondfrancis

View GitHub Profile
@Daniel-Hug
Daniel-Hug / arr-stat.js
Last active December 11, 2023 14:46
JavaScript statistical functions for arrays: max, min, range, midrange, sum, mean / average, median, modes, variance, standard deviation, mean absolute deviation, z scores
var arr = {
max: function(array) {
return Math.max.apply(null, array);
},
min: function(array) {
return Math.min.apply(null, array);
},
range: function(array) {
@tpavlek
tpavlek / combinations.php
Created June 2, 2016 22:12
Get all combinations of two collections
<?php
/**
* If you have two sets of collections, which you would previously have used a nested foreach to do something to each unique
* combination of items, you can use this macro to get it done instead!
*
* It will return a collection of tuples that represent the combination of the two collections. If you'd like to add keys to the tuple
* you can pass that in as an optional second argument!
*/
@mhawksey
mhawksey / gist:1276293
Last active October 23, 2023 09:00
Google App Script to insert data to a google spreadsheet via POST or GET - updated version as per https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@reinink
reinink / DateInput.vue
Created August 27, 2019 11:51
Pikaday Vue Component
<template>
<div>
<label v-if="label" class="form-label" :for="`date-input-${_uid}`">{{ label }}:</label>
<input v-bind="$attrs" class="form-input" :id="`date-input-${_uid}`" :class="{ error: error }" type="text" ref="input" :value="value" @change="change" @keyup="change">
<div v-if="error" class="form-error">{{ error }}</div>
</div>
</template>
<script>
import pikaday from 'pikaday'
@stephenfeather
stephenfeather / analytics.js
Created June 2, 2012 18:09
commonJS version of Roger Chapman's Google Analytics Library for Appcelerator's Titanium Mobile SDK
/*
The MIT License
Copyright (c) 2010 Roger Chapman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
<?php
//////////////////////////////////
// Reddit "hot" story algorithm //
//////////////////////////////////
function hot($ups, $downs, $date)
{
if (is_string($date)) $date = strtotime($date);
$s = $ups - $downs;
@taylorotwell
taylorotwell / global-homestead.sh
Created September 23, 2015 21:40
Global Homestead Without Composer
alias homestead='function __homestead() { (cd ~/Documents/Code/Homestead && vagrant $*); unset -f __homestead; }; __homestead'
# Usage
homestead up
homestead halt
# etc...
@paulkaplan
paulkaplan / retina_fabric.js
Created July 21, 2013 22:47
Getting fabric.js to work with Retina screens
if( window.devicePixelRatio !== 1 ){
var c = canvas.getElement(); // canvas = fabric.Canvas
var w = c.width, h = c.height;
// Scale the canvas up by two for retina
// just like for an image
c.setAttribute('width', w*window.devicePixelRatio);
c.setAttribute('height', h*window.devicePixelRatio);
@mschmulen
mschmulen / app.js
Created November 13, 2012 19:08
aws queu
var AWS;
var queueName = 'TestQueue110512';
var awsAccountId = Ti.App.Properties.getString('aws-account-id');
function pretty(key, value) {
if ((key == 'source') || (key == 'type')) {
return undefined;
} else {
return value;
@pec1985
pec1985 / app.js
Created November 1, 2012 22:11
Double Slider
var DoubleSlider = require('ti.doubleslider/widget');
var win = Ti.UI.createWindow();
var doubleSlider = new DoubleSlider({
top: 50,
width: 300,
minValue: 0,
maxValue: 100,
startValue: 30,