Skip to content

Instantly share code, notes, and snippets.


Ryan Brown ryantbrown

View GitHub Profile
ryantbrown / es-nested-agg-nested-query.json
Last active Feb 27, 2018
Elastic search nested aggregate with nested query
View es-nested-agg-nested-query.json
GET influencers/_search
"size": 0,
"aggregations": {
"influencers": {
"nested": {
"path": "interests"
"aggs": {
"names": {
ryantbrown / composer.json
Created Feb 21, 2018
Private composer package
View composer.json
// main app
"repositories" : [
"type": "package",
"package": {
"name": "grininc/platform-shared",
"version": "dev-master",
"source": {
"url": "git://",
"type": "git",
ryantbrown /
Created Feb 1, 2018
Bash script to Upload folder to S3
# Set AWS credentials and S3 paramters
function s3Upload
ryantbrown / click-outside-element.js
Last active Apr 30, 2018
Handle a click outside of a parent element
View click-outside-element.js
// the parent, avoid clicks inside this element
const parent = document.getElementById('parent');
window.addEventListener('click', e => {
let elem =;
// loop through the target's parent nodes to see if it matches
for ( ; elem && elem !== document; elem = elem.parentNode ) {
ryantbrown / checkbox.css
Last active Aug 14, 2018
SVG based checkbox
View checkbox.css
.checkbox {
height: 40px;
width: 40px;
outline: none;
cursor: default;
border: 0;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
ryantbrown / time-elapsed.php
Last active Apr 30, 2018
Get days, hours and minutes that have passed from a given date
View time-elapsed.php
// get interval
// format of $datetime is "Y-m-d H:i:s"
$interval = (new \DateTime("now"))->diff(new \DateTime($datetime));
// get specific times
list($days, $hours, $minutes) = explode(" ", $interval->format("%d %h %i"));
View Dockerfile
FROM php:5.6-fpm
RUN apt-get update && apt-get install -y git curl
RUN docker-php-ext-install -j$(nproc) pdo_mysql
RUN docker-php-ext-install -j$(nproc) mbstring
RUN docker-php-ext-install -j$(nproc) tokenizer
RUN curl -sS "" | php
RUN chmod a+x composer.phar && mv composer.phar /usr/local/bin/composer
ryantbrown / auto-validation-semantic-ui.js
Created Apr 16, 2015
Semantic UI - Auto Validation via Data Attrs
View auto-validation-semantic-ui.js
// form validation loaded from config
var config = $(this).data('config');
if(config !== undefined) {
$(this).prepend('<div class="ui icon error message" id="form-errors"></div>');
var settings = APP.config.validation;
config.split('.').forEach(function(el, i, arr){
ryantbrown / gulp-resize-and-minify-images.js
Last active Mar 23, 2021
Gulp - Resize and Optimize / Minify Images
View gulp-resize-and-minify-images.js
* Make sure Graphicsmagick is installed on your system
* osx: brew install graphicsmagick
* ubuntu: apt-get install graphicsmagick
* Install these gulp plugins
* glup, gulp-image-resize, gulp-imagemin and imagemin-pngquant
* Group images according to their output dimensions.
* (ex: place all portfolio images into "images/portfolio"
cd ~ && wget
tar xvzf redis-stable.tar.gz
cd redis-stable
sudo cp src/redis-server /usr/local/bin/
sudo cp src/redis-cli /usr/local/bin/
# redis is now installed but we need to proof it
sudo mkdir /etc/redis
sudo mkdir /var/redis
sudo cp utils/redis_init_script /etc/init.d/redis_6379