Skip to content

Instantly share code, notes, and snippets.

@laranea
laranea / stages.md
Created February 27, 2018 10:22 — forked from lestrrat/stages.md
Seven Stages of Becoming a Go Programmer
  • 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
@laranea
laranea / import-db.sh
Created February 21, 2019 13:01 — forked from hartleybrody/import-db.sh
Copy data from Heroku Postgres into local database
# 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
@laranea
laranea / hrtool.py
Created June 10, 2019 14:16 — forked from miratcan/hrtool.py
A python script to run hackerrank answers on your local. Just run it in the sample test cases folder that you downloaded from hackerrank.
import re
import glob
import subprocess
from os.path import exists
from sys import exit
INPUT_FOLDER = 'input/'
OUTPUT_FOLDER = 'output/'
@laranea
laranea / genetic_function.py
Created January 6, 2020 19:32 — forked from xav-b/genetic_function.py
Genetic optimization of a trading strategy for zipline backtester
import time
import random
import math
import numpy as np
import logbook
log = logbook.Logger('Optimization')
from neuronquant.network.transport import ZMQ_Dealer
@laranea
laranea / upgrade_postgres
Created January 11, 2020 23:13 — forked from wosephjeber/upgrade_postgres
Upgrade from postgres 9.6.2 to 10.5 on OSX
## 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
@laranea
laranea / sqlalchemy_snippet.py
Created January 14, 2020 07:27 — forked from mumumu/sqlalchemy_snippet.py
sqlalchemy snippet.
#!/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()
@laranea
laranea / sqlalchemy_snippet.py
Created January 14, 2020 07:27 — forked from mumumu/sqlalchemy_snippet.py
sqlalchemy snippet.
#!/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()
@laranea
laranea / interactive_google_oauth2.py
Created February 24, 2020 09:53 — forked from frankie567/interactive_google_oauth2.py
Interactive Google OAuth2 flow with Streamlit
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")
@laranea
laranea / interactive_google_oauth2.py
Created February 24, 2020 09:53 — forked from frankie567/interactive_google_oauth2.py
Interactive Google OAuth2 flow with Streamlit
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")