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
@daino3
daino3 / image_transformatation.py
Last active December 12, 2021 11:51
Converting an image data uri to (28, 28) numpy array and writing to csv
from PIL import Image
import base64
import numpy
from io import BytesIO
data_uri = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAS4AAAEuCAYAAAAwQP9DAAAU80lEQVR4Xu2da+hnRRnHv0qZKV42LDOt1eyGULoSJBGpRBFprBJBQrBJBBWGSm8jld5WroHUCyEXKutNu2IJ1QtXetULL0uQFCu24WoRsV5KpYvGYzM4nv6X8zu/mTnznPkcWP6XPTPzzOf7/L7/OXPmzDlOHBCAAAScETjOWbyECwEIQEAYF0kAAQi4I4BxuZOMgCEAAYyLHIAABNwRwLjcSUbAEIAAxkUOQAAC7ghgXO4kI2AIQADjIgcgAAF3BDAud5IRMAQggHGRAxCAgDsCGJc7yQgYAhDAuMgBCEDAHQGMy51kBAwBCGBc5AAEIOCOAMblTjIChgAEMC5yAAIQcEcA43InGQFDAAIYFzkAAQi4I4BxuZOMgCEAAYyLHIAABNwRwLjcSUbAEIAAxkUOQAAC7ghgXO4kI2AIQADjIgcgAAF3BDAud5IRMAQggHGRAxCAgDsCGJc7yQgYAhDAuMgBCEDAHQGMy51kBAwBCGBc5AAEIOCOAMblTjIChgAEMC5yAAIQcEcA43InGQFDAAIYFzkAAQi4I4BxuZOMgCEAAYyLHIAABNwRwLjcSUbAEIAAxkUOQAAC7ghgXO4kI2AIQADjIgcgAAF3BDAud5IRMAQggHGRAxDwTeDTkr4s6UxJ/5F0QNK3JD3lu1tbR49xLVld+jYXgcskvSTpIkmnS/qgpJMk/Tv8bHHZ7+PXPw6M5kRJx0t6Ijkv9uUsSW+U9Iykczfp4K8lfXiuztdoF+OqQZk2vBEwUzFTsK9mQNFkotGkhvFeSc+G86NRtdDfd0h6tIVASsSAcZWgSp0eCJjJ7JR0SRgZ2SjHDMp+38Jho7PXTAzkBUmvn1jWRTGMy4VMBJmBg
package main
import (
"fmt"
"github.com/fatih/color"
"github.com/fsnotify/fsnotify"
"log"
"os"
"path/filepath"
"regexp"
import axios from 'axios';
import {toCamelCase, toSnakeCase} from '../util';
import qs from 'qs';
// You can intercept requests or responses before they are handled by then or catch.
// https://github.com/axios/axios#interceptors
// Add a response interceptor and camelCase return data (for JS)
axios.interceptors.response.use((response) => {
response.data = toCamelCase(response.data);
@daino3
daino3 / example.js
Last active November 13, 2017 16:07
import React, {Component} from "react";
import {validateEmail, validateRequired} from "./validations";
class MyForm extends Component {
render(
return (<Input id="email"
placeholder="[email protected]"
label="Email (*Required)"
type="text"
validators={[validateEmail, validateRequired]}
@daino3
daino3 / main.yml
Last active February 2, 2018 23:49
Ansible role for installing phantomjs on Ubuntu
---
# exists at roles/phantomjs/tasks/main.yml
- name: Update repositories cache and system deps
apt: name={{ item }} state=present update_cache=yes
with_items:
- build-essential
- chrpath
- libssl-dev
- libxft-dev
@daino3
daino3 / main.yml
Created February 3, 2018 03:46
Installing Chrome Driver on ubuntu
- name: Update repositories cache and system deps
apt: name={{ item }} state=present update_cache=yes
with_items:
- libxi6
- libgconf-2-4
- name: Install chromedriver
apt: name={{ item }} state=present
with_items:
- chromium-chromedriver
@daino3
daino3 / ansible-bootstrap-ubuntu-16.04.yml
Created February 7, 2018 18:07 — forked from gwillem/ansible-bootstrap-ubuntu-16.04.yml
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# [email protected]
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@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
@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);
+import moment from "moment/moment";
+
+//
+
+class CachedResource {
+ constructor(
+ cachedResourceKey,
+ cachedTimestampKey,
+ source,
+ dirtyFunc,