Skip to content

Instantly share code, notes, and snippets.

View blainegarrett's full-sized avatar
💭
Build things to better the world.

Blaine Garrett blainegarrett

💭
Build things to better the world.
View GitHub Profile
@blainegarrett
blainegarrett / stats_created_per_gallery
Created June 11, 2018 15:33
Number of events per gallery
@blainegarrett
blainegarrett / prefs_export.py
Created April 23, 2018 16:32
Remote Console Script to Dump Pref Data to CSV
# Generate a csv of the prefs data
# In the ./app dir execute: remote_api_shell.py -s pref-service.appspot.com
import csv
from api.entities import PreferenceEntity
from rest_core.utils import get_resource_id_from_key
q = PreferenceEntity.query()
cursor = None
@blainegarrett
blainegarrett / sdk_options_hack.txt
Created April 7, 2018 18:16
App Engine SDK OPTIONS /_ah/upload/ hack
if environ['REQUEST_METHOD'] == 'OPTIONS' and environ['REQUEST_URI'][0:12] == '/_ah/upload/':
logging.warning("Hacked OPTIONS request for /_ah/upload - see module.828")
wrapped_start_response('200 SUPER GREAT',
[
('Access-Control-Allow-Origin', '*'),
('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE'),
('Access-Control-Allow-Credentials', 'true'),
('Content-Type', 'application/json'),
('Access-Control-Allow-Headers', '*'),
])
@blainegarrett
blainegarrett / stats_created_per_month
Last active June 11, 2018 14:07
Calculate # of events created per month
# In the ./app dir execute: remote_api_shell.py -s arts-612.appspot.com
# Script to get all the events listed by when they were posted
from app.modules.events.internal.entities import EventEntity
q = EventEntity.query()
hist = {}
cursor = None
more = True
while(more):
@blainegarrett
blainegarrett / grid.js
Created March 19, 2018 22:45
Material UI Next classic Grid Iterface
import React from 'react';
import PropTypes from 'prop-types';
import MuiGrid from 'material-ui/Grid';
import { withStyles } from 'material-ui/styles';
import classNames from 'classnames';
const styles = (theme) => {
// console.log(theme.spacing.unit);
// theme.spacing.unit * 2
@blainegarrett
blainegarrett / divirod_survey_sync.py
Last active May 9, 2017 04:00
Divining Rod Survey Data Sync
import csv
import requests # installed (pip install requests)
import json
INPUT_FILE = './data/diving-rods-survey-data-2017-04-24.csv'
BATCH_SIZE = 100
PREF_API_URL = 'http://localhost:9090/api/rest/v1.0/preferences'
def submit_pref_data(data):
// Simple React Class for managing the loading state of an image asset
var ImgLoader = React.createClass({
loadHandler: function () {
this.setState({img_loaded: true});
},
getInitialState: function () {
return {
loading_src: 'https://dummyimage.com/700x700/ccc/ffffff.png&text=loading...',
img_loaded: false
}
@blainegarrett
blainegarrett / test.py
Created August 31, 2016 14:00
Instagram Assemble
"""
Initial draft of helper code to create an 700x700 instagrammable image coponsed of other cover images.
"""
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from math import ceil