Skip to content

Instantly share code, notes, and snippets.

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 Jun 11, 2018
Number of events per gallery
View stats_created_per_gallery
@blainegarrett
blainegarrett / prefs_export.py
Created Apr 23, 2018
Remote Console Script to Dump Pref Data to CSV
View prefs_export.py
# 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 Apr 7, 2018
App Engine SDK OPTIONS /_ah/upload/ hack
View sdk_options_hack.txt
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 Jun 11, 2018
Calculate # of events created per month
View stats_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 Mar 19, 2018
Material UI Next classic Grid Iterface
View grid.js
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
Divining Rod Survey Data Sync
View divirod_survey_sync.py
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):
View react_img_loader.js
// 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 Aug 31, 2016
Instagram Assemble
View test.py
"""
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