Skip to content

Instantly share code, notes, and snippets.

View singingwolfboy's full-sized avatar
Available for contract work

David Baumgold singingwolfboy

Available for contract work
View GitHub Profile
<input onClick={function() {}} />
class Component extends React.Component {
propTypes = {
onClick: PropTypes.func,
}
handleClick = e => {
// do stuff
this.props.onClick()
import { doStuff } from "parent";
export handle = (data, context, callback) => {
return doStuff(data, context, callback, "custom-arg-1");
}
{
"type": "object",
"properties": {
"user": {
"description": "The user that is selecting her peers",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
@singingwolfboy
singingwolfboy / oauth.py
Last active October 29, 2017 09:36
Creating local users on successful OAuth login with Flask-Dance
import flask
from flask import redirect, url_for, flash
from flask_security import current_user, login_user
from flask_dance.consumer import oauth_authorized, oauth_error
from flask_dance.consumer.backend.sqla import SQLAlchemyBackend
from flask_dance.contrib.github import make_github_blueprint
from sqlalchemy.orm.exc import NoResultFound
from myapp.models import db, OAuth, User
@singingwolfboy
singingwolfboy / print_repo_labels.py
Created September 7, 2017 21:07
Prints the labels from a GitHub repository, one per line.
# This requires the Requests module, which is a 3rd-party module: python-requests.org
# Install with: `pip install requests`
import requests
def paginated_get(url):
"""
Create a generator of objects from the GitHub API,
while traversing Link headers for pagination.
"""
response = requests.get(url)
@singingwolfboy
singingwolfboy / console.py
Created March 18, 2017 17:13
iterable unpacking works with generators, too!
>>> def generator():
... yield 4
... yield 5
...
>>> x, y = generator()
>>> x
4
>>> y
5
>>> # mind blown!!
web_1 | [2017-02-27 15:36:06] ERROR 437 [django.request] exception.py:124 - [6a1da3000f19] - Internal Server Error: /api/v0/search/_search
web_1 | Traceback (most recent call last):
web_1 | File "/usr/local/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
web_1 | response = get_response(request)
web_1 | File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
web_1 | response = self._get_response(request)
web_1 | File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response
web_1 | response = self.process_exception_by_middleware(e, request)
web_1 | File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response
web_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
@singingwolfboy
singingwolfboy / output.log
Created February 13, 2017 06:06
Problem running Lektor tests on Ubuntu
$ vagrant init ubuntu/xenial64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/xenial64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
➜ micromasters git:(master) docker-compose run web ./manage.py seed_db
/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py:1430: RuntimeWarning: DateTimeField CourseRun.enrollment_start received a naive datetime (2016-08-15 00:00:00) while time zone support is active.
RuntimeWarning)
/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py:1430: RuntimeWarning: DateTimeField CourseRun.start_date received a naive datetime (2016-08-15 00:00:00) while time zone support is active.
RuntimeWarning)
/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py:1430: RuntimeWarning: DateTimeField CourseRun.enrollment_end received a naive datetime (2016-08-29 00:00:00) while time zone support is active.
RuntimeWarning)
/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py:1430: RuntimeWarning: DateTimeField CourseRun.end_date received a naive datetime (2016-12-15 00:00:00) while time zone support is active.
RuntimeWarning)
/usr/local
celery_1 | [2017-01-30 16:55:33,110: ERROR/MainProcess] Task search.tasks.index_users[a11ccd3d-b0d4-435a-b3d1-4a80129fbfd0] raised unexpected: DoesNotExist('FinalGrade matching query does not exist.',)
celery_1 | Traceback (most recent call last):
celery_1 | File "/usr/local/lib/python3.5/site-packages/celery/app/trace.py", line 240, in trace_task
celery_1 | R = retval = fun(*args, **kwargs)
celery_1 | File "/usr/local/lib/python3.5/site-packages/celery/app/trace.py", line 438, in __protected_call__
celery_1 | return self.run(*args, **kwargs)
celery_1 | File "/src/search/tasks.py", line 44, in index_users
celery_1 | _index_users(users)
celery_1 | File "/src/search/indexing_api.py", line 143, in index_users
celery_1 | return index_program_enrolled_users(program_enrollments, chunk_size)