Skip to content

Instantly share code, notes, and snippets.

@kosyfrances
kosyfrances / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kosyfrances
kosyfrances / deploy_python_bot.md
Last active January 7, 2016 09:03
Deploying a pure python slack-bot on heroku

This is not explanatory, and I have plans to explain better in my up-coming blog. It was difficult for me to find comprehensive information for pure python apps when I wanted to deploy my bot to heroku

Follow this process: https://devcenter.heroku.com/articles/getting-started-with-python Scale the worker process with heroku ps:scale worker=1 to keep the bot process running

@kosyfrances
kosyfrances / multiple_env_heroku.txt
Created December 7, 2015 22:05
Managing multiple environments for an app in heroku
Follow the instructions here -
https://devcenter.heroku.com/articles/multiple-environments#starting-from-an-existing-app
@kosyfrances
kosyfrances / heroku_database_copy.md
Last active March 15, 2023 09:50
To copy heroku database from one app to another and from local to heroku

To copy database from one heroku app to another -

heroku pg:backups capture [database_name]
heroku pg:backups restore $(heroku pg:backups public-url --app source_app) DATABASE_URL --app target_app

You can refer to https://devcenter.heroku.com/articles/heroku-postgres-backups for more information.

To copy database from local to heroku - Dump your local database in compressed format using the open source pg_dump tool: PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump where myuser is your database username and mydb is the database name.

@kosyfrances
kosyfrances / python_test.md
Last active January 7, 2016 09:01
To run all tests in files in a folder in python
@kosyfrances
kosyfrances / coverage.md
Last active January 7, 2016 08:54
To combine multiple coverage reports in coverage.py
@kosyfrances
kosyfrances / aws_ec2.md
Last active January 7, 2016 08:53
Setting up and launching an Amazon EC2 ubuntu instance.

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizeable computing capacity—literally, servers in Amazon's data centers—that you use to build and host your software systems.

If you are new to Amazon EC2. First set up using this link. http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/get-set-up-for-amazon-ec2.html

Then launch and connect to your new instance using this http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html

If you need to create a nonroot user, here’s how:

# these commands must be run as root
root@server:$ useradd -m -s /bin/bash elspeth # add user named elspeth
@kosyfrances
kosyfrances / unknown_locale.md
Last active January 21, 2016 09:02
unknown locale: UTF-8 error

We had this error when I was trying to use django rest swagger in the api we built,

unknown locale: UTF-8
Request Method:	GET
Request URL: http://localhost:8000/docs
Django Version:	1.8.2
Exception Type:	ValueError
Exception Value:	
unknown locale: UTF-8```
@kosyfrances
kosyfrances / selenium_firefox_tdd.md
Last active September 6, 2020 22:31
Unable to call firefox from selenium in python on AWS machine while running functional tests

While trying to run functional tests in python on an Ubuntu EC2 instance using
python manage.py test functional_tests --liveserver=superlist-staging.tk

I got this error
RuntimeError: Could not find firefox in your system PATH. Please specify the firefox binary location or install firefox So I did sudo apt-get install firefox to install firefox.

Afterwards I tried running the tests again and got another error:
WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

@kosyfrances
kosyfrances / uninstall.txt
Created January 15, 2016 10:47
To uninstall what is not in requirements.txt
To uninstall what is not in requirements.txt
pip freeze | grep -v -f requirements.txt - | xargs pip uninstall -y