Skip to content

Instantly share code, notes, and snippets.

View daino3's full-sized avatar

Dain Hall daino3

  • SpotOn, Inc
  • Chicago, Il
View GitHub Profile
import React from 'react';
import { useSpring, animated } from 'react-spring';
import { useDrag } from 'react-use-gesture';
import PropTypes from 'prop-types';
const THRESHOLD_PX = 100;
function AnimatedSwipeNavigation({ onSwipeLeft, onSwipeRight, vertical = false, horizontal = true, children }) {
const [{ x, y }, set] = useSpring(() => ({ x: 0, y: 0 }));
@daino3
daino3 / cohort.sql
Last active January 26, 2020 03:16
-- COHORT ANALYSIS
-- (merchant_location_id, cohort_month), each
with cohort_items as (
select
date_trunc('month', ML.created_at)::date as cohort_month,
id as merchant_location_id
from merchant_locations ML
),
-- (merchant_location_id, month_number): merchant X has activity in month number X
merchant_appointments as (
class Sidebar extends React.Component {
// this class will be responsible
// for positioning, styles, animations, etc.
// and that's about it...
render() {
const {
isOpen,
children,
} = this.props
return (
defmodule WebsocketApi.MerchantLocationChannel do
use WebsocketApi.Web, :channel
alias WebsocketApi.{
DeviceWatcher,
MerchantLocation,
MerchantLocationDevice,
Repo
}
require Logger
@moduledoc false
document.addEventListener('scroll', this.onScroll);
function onScroll() {
const offSet = this.getOffset();
const midScreen = window.innerHeight / 2;
let opacity = 1;
// element is in viewport
if (Math.abs(offSet) < midScreen) {
// *pow to amplify opacity
@daino3
daino3 / rebuild_vm
Last active November 9, 2018 19:52
#!/bin/sh
BOXNAME=`date +'vm_box_%m%d%Y_%H%M%S'`
vagrant destroy --force || exit $?
PACKAGING_BASE_BOX=1 vagrant up || exit $?
PACKAGING_BASE_BOX=1 vagrant package --out "$BOXNAME.box" || exit $?
vagrant box add $BOXNAME "./$BOXNAME.box" || exit $?
aws s3 cp "$BOXNAME.box" "s3://vagrant-boxes/" || exit $?
@daino3
daino3 / Vagrant
Last active July 26, 2018 17:22
s3 vagrant images
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# name of virtualbox
config.vm.provider :virtualbox do |vb|
+import moment from "moment/moment";
+
+//
+
+class CachedResource {
+ constructor(
+ cachedResourceKey,
+ cachedTimestampKey,
+ source,
+ dirtyFunc,
@daino3
daino3 / FileUpload.js
Created February 23, 2018 17:44 — forked from BilalBudhani/FileUpload.js
Upload Multiple Files To Cloudinary With React & Axios
handleDrop = files => {
// Push all the axios request promise into a single array
const uploaders = files.map(file => {
// Initial FormData
const formData = new FormData();
formData.append("file", file);
formData.append("tags", `codeinfuse, medium, gist`);
formData.append("upload_preset", "pvhilzh7"); // Replace the preset name with your own
formData.append("api_key", "1234567"); // Replace API key with your own Cloudinary key
formData.append("timestamp", (Date.now() / 1000) | 0);
@daino3
daino3 / s3Sync.sh
Created February 8, 2018 20:46 — forked from kellyrmilligan/s3Sync.sh
Sync files to s3 and set cache control headers
#!/bin/bash
if [[ "$1" != "" ]]; then
S3BUCKETNAME="$1"
else
echo ERROR: Failed to supply S3 bucket name
exit 1
fi
aws s3 sync build s3://$S3BUCKETNAME --delete --cache-control max-age=31536000,public