Skip to content

Instantly share code, notes, and snippets.

View ArnoutDevos's full-sized avatar
🎯
Focusing

Arnout Devos ArnoutDevos

🎯
Focusing
View GitHub Profile
@ArnoutDevos
ArnoutDevos / how-to-upgrade-heroku-postgresql.md
Last active July 9, 2024 18:44 — forked from simonw/how-to-upgrade-heroku-postgresql.md
How to upgrade a Heroku PostgreSQL database to a new plan

How to upgrade a Heroku PostgreSQL database to a new plan

original: https://gist.github.com/simonw/50e14b9a3e829355d6d43f0f12f91e74

I started a project on a Hobby Dev plan (free, limit 10,000 rows), and then later needed to upgrade it to Hobby Basic ($9/month, limit 10,000,000 rows).

⚠️ In the following, replace <appname> with the name of your Heroku app.

What database(s) are connected?

@ArnoutDevos
ArnoutDevos / install.sh
Created April 18, 2019 11:50
ReScience-C template required installs (macOS)
git clone https://github.com/rescience-c/template.git
cd template
brew tap caskroom/cask
brew cask install mactex
make draft
@ArnoutDevos
ArnoutDevos / Remove_notebook_checkpoints.sh
Created December 7, 2018 10:08
command to remove automatically created .ipynb_checkpoints folders and their checkpoints
rm -rf `find -type d -name .ipynb_checkpoints`
@ArnoutDevos
ArnoutDevos / gist:0670249b6090cddce202a015945fba16
Created October 10, 2018 16:29
Create conda virtual environment and add it to jupyter
# Inspiration from
# https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/
# and
# https://stackoverflow.com/questions/39604271/conda-environments-not-showing-up-in-jupyter-notebook
# Check if conda is up to date
conda update conda
# Create a virtual environment for your project
conda create -n myenv python=x.x anaconda
import cv2
def imgread(path):
print "Image:", path.split("/")[-1]
# Read in the image using python opencv
img = cv2.imread(path)
img = img / 255.0
print "Raw Image Shape: ", img.shape
# Center crop the image
@ops.RegisterGradient("GuidedRelu")
def _GuidedReluGrad(op, grad):
return tf.where(0. < grad, gen_nn_ops._relu_grad(grad, op.outputs[0]), tf.zeros(grad.get_shape()))
# Number of iterations to run.
ITERATIONS = 500
sess.run(tf.global_variables_initializer())
input_image = np.reshape(gen_image, ((1,) + gen_image.shape))
sess.run(model['input'].assign(input_image))
for it in range(ITERATIONS):
sess.run(train_step)
if it%50 == 0:
# Print every 50 iteration.
# Content loss emphasis.
ALPHA = 0.0025
# Style loss emphasis.
BETA = 1
total_loss = ALPHA * content_loss + BETA * style_loss
optimizer = tf.train.AdamOptimizer(2.0)
train_step = optimizer.minimize(total_loss)
sess = tf.InteractiveSession()
model = load_vgg_model(VGG_MODEL)
# Construct content_loss using content_image.
content_image_list = np.reshape(content_image, ((1,) + content_image.shape))
sess.run(model['input'].assign(content_image_list))
content_loss = content_loss_func(sess, model)
# Construct style_loss using style_image.
STYLE_LAYERS = [
('conv1_1', 0.5),
('conv2_1', 0.5),
('conv3_1', 0.5),
('conv4_1', 0.5),
('conv5_1', 0.5),
]
def style_loss_func(sess, model):
def _gram_matrix(feat):