Skip to content

Instantly share code, notes, and snippets.

View scott-coates's full-sized avatar

Scott Coates scott-coates

View GitHub Profile
Name Followers Genre(s) Related Artists
"The Musical Adventures of Grace" - Book Reading Session at Appleton Public Library
@scott-coates
scott-coates / demo.js
Last active April 20, 2020 13:21
A React.js wrapper for the nanoScroller library. https://jamesflorentino.github.io/nanoScrollerJS/.
import ScrollContainer from 'nanoScroller-react.js';
export default React.createClass({
render() {
return (
<nav id="sidebar-wrapper">
<ScrollContainer id="sidebar-scroll-container">
<ul>
@scott-coates
scott-coates / after.js
Last active August 23, 2017 23:44
Imperative vs FRP code. 'Subscribe' to a Redux Store, only receiving events when a specific piece of state is changed.
const teamStream = storeObserver.observeStateStream(store, state => state.team.requestedTeam.id);
teamStream.onValue(requestedTeamId => {
// clean up old connection (this will happen if we look at different teams)
if (this.teamRef) this.teamRef.off('value', this.teamCallback);
this.teamRef = rootRef.child(`teams/${requestedTeamId}`);
this.teamCallback = this.teamRef.on('value', snapshot => {
try {
@scott-coates
scott-coates / mock-api-es6.js
Last active August 29, 2015 14:22
A slightly biased comparison of ES7 async/await (a la C#) vs ES6 promises. The idea is to delay the return of data, simulating a a request/response from a server.
const mockAPI = {
provideResponse(dataToProvide) {
const timeout = Math.round(Math.random() * (3000 - 500)) + 500;
const retVal = new Promise((resolve, reject)=> {
setTimeout(() => {
resolve(dataToProvide);
}, timeout);
@scott-coates
scott-coates / python_remote_console.py
Last active August 29, 2015 13:58
Pycharm 3 & IntelliJ 13 don't honor the `working directory` option for remote python consoles. See here: http://youtrack.jetbrains.com/issue/PY-12239
# Go to Settings -> Console -> Python Console (Do not use Django Console - even if you plan to use this with a Django project)
# Ad this gist to the "starting script" option.
import os
# Chdir to "working directory"
os.chdir('/vagrant')
import sys
sys.path.extend([ '/home/vagrant/.pycharm_helpers/pycharm', '/home/vagrant/.pycharm_helpers/pydev'])
import django_manage_shell; django_manage_shell.run("/vagrant")
# Django 1.7 app loading
import django
@scott-coates
scott-coates / enable_south_migrations.py
Created August 29, 2013 16:51
If you are running some django tests in an environment where you want to force south to run, you can use this gist. This was taken from the pycharm test runner.
from django.core import management
from django.conf import settings
def enable_south_migrations():
management.get_commands()
if hasattr(settings, "SOUTH_TESTS_MIGRATE") and not settings.SOUTH_TESTS_MIGRATE:
# point at the core syncdb command when creating tests
# tests should always be up to date with the most recent model structure
management._commands['syncdb'] = 'django.core'
@scott-coates
scott-coates / Rakefile.rb
Created July 26, 2013 23:02 — forked from nextlanding/Rakefile.rb
This is a simple rake task to deploy an app to heroku.
# Deploy and rollback on Heroku in qa and production
# sources: https://gist.github.com/njvitto/362873
# https://gist.github.com/djburdick/4410411
task :deploy_qa_light => ['deploy:set_qa_app', 'deploy:push', 'deploy:tag']
task :deploy_production_light => ['deploy:set_production_app', 'deploy:push', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'my-heroku-prod-app'
QA_APP = 'my-heroku-qa-app'