- stage 1: You believe you can make Go do object oriented programming. You want to do this by using clever struct embedding.
- stage 2: You believe goroutines will solve all of your problems. You want to use goroutines for anything and everything that you can, who cares if the code becomes a bit more complicated
- stage 3: You believe that instead of object oriented programming, interfaces will solve all of your problems. You want to define everything in terms of interfaces
- stage 4: You believe channels will solve all of your problems. You want to do everything from synchronization, returning values, and flow control using channels.
- stage 5: You now believe Go is not as powerful as people claim it to be. You feel like you're stripped of all of the nice tools and constructs that other languages provide.
- stage 6: You realize that stages 1~5 were all just your imagination. You just didn't want to accept the Go way. Everything starts to make sense.
- stage 7: You are now at peace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy/import data from heroku postgres to localhost pg database | |
# useful for copying admin's work on live site into local database to reproduce errors | |
# https://devcenter.heroku.com/articles/heroku-postgres-import-export | |
# take heroku pg snapshot and download | |
heroku pg:backups:capture | |
heroku pg:backups:download | |
# load the dump into local postgres database, assuming $DATABASE_URL set locally |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import glob | |
import subprocess | |
from os.path import exists | |
from sys import exit | |
INPUT_FOLDER = 'input/' | |
OUTPUT_FOLDER = 'output/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import random | |
import math | |
import numpy as np | |
import logbook | |
log = logbook.Logger('Optimization') | |
from neuronquant.network.transport import ZMQ_Dealer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Following these commands should upgrade and migrate your existing database. | |
## This is an example of going from 9.6.2 to 10.5 on OSX. | |
## Be sure to update any version numbers based on the versions you're upgrading from and to. | |
## Adapted from https://stackoverflow.com/questions/24379373/how-to-upgrade-postgresql-from-version-9-6-to-version-10-1-without-losing-data | |
## Backup your database, just in case (replace databasename with your actual DB name) | |
pg_dump databasename > ~/Desktop/dev_dump | |
## Stop postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from sqlalchemy import create_engine | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, Integer, String | |
from sqlalchemy.orm import sessionmaker | |
engine = create_engine('sqlite:///:memory:', echo=True) | |
Session = sessionmaker(bind=engine) | |
Base = declarative_base() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from sqlalchemy import create_engine | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, Integer, String | |
from sqlalchemy.orm import sessionmaker | |
engine = create_engine('sqlite:///:memory:', echo=True) | |
Session = sessionmaker(bind=engine) | |
Base = declarative_base() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import streamlit as st | |
from httpx_oauth.clients.google import GoogleOAuth2 | |
st.title("Google OAuth2 flow") | |
"## Configuration" | |
client_id = st.text_input("Client ID") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import streamlit as st | |
from httpx_oauth.clients.google import GoogleOAuth2 | |
st.title("Google OAuth2 flow") | |
"## Configuration" | |
client_id = st.text_input("Client ID") |