Skip to content

Instantly share code, notes, and snippets.

@kosyfrances
kosyfrances / site-to-site.md
Last active April 19, 2024 17:10
Steps to set up one tunnel IPSec Site to site VPN on AWS and a VM on another cloud provider (Packet) running Strongswan
@kosyfrances
kosyfrances / terraform_template_to_file
Created November 29, 2019 13:10
Render terraform template to local file tested on Terraform v0.12.16
locals {
our_rendered_content = templatefile("${path.module}/yourtemplatefile.tmpl", { yourvars = var.yourvars })
}
resource "null_resource" "local" {
triggers = {
template = local.our_rendered_content
}
# Render to local file on machine
@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 / libvirt-kvm-docker.md
Last active February 2, 2023 16:32
Spin up a Libvirt VM (that supports nested virtualisation using KVM as Hypervisor) in a docker container.

Dockerfile

FROM ubuntu:18.04
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils vagrant && \
    apt-get autoclean && \
    apt-get autoremove && \
    vagrant plugin install vagrant-libvirt
COPY startup.sh /
ENTRYPOINT ["/startup.sh" ]
@kosyfrances
kosyfrances / README.md
Created February 21, 2019 13:36 — forked from johananl/README.md
KVM in runc

KVM in runc

Running a KVM virtual machine inside a runc contianer.

Requirements

  • A host which can run KVM virtual machines using Vagrant.

Setting up a test VM

@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 / git_olduser_403.md
Created June 15, 2016 19:30
Pushing to Git returned error 403 with old git username instead of new

When I tried to push to Github, it gave me this error.

remote: Permission to NEWUSER/NEWREPO.git denied to OLDUSER. 
fatal: unable to access ‘https://github.com/NEWUSER/NEWREPO.git/': The requested URL returned error: 403

But setting the user.name and email globally should have fixed it, No it did not. So I got it fixed by deleting the OLDUSER associated with GitHub from Keychain Access app under Passwords section. Then the push command went successful. :)

@kosyfrances
kosyfrances / ansible_unknown_encoding.md
Created May 8, 2016 20:40
Running ansible playbook gives unknown encoding error

While running ansible playbook, I encountered this error

Traceback (most recent call last):
  File "/usr/local/bin/ansible-playbook", line 110, in <module>
    display.error("Unexpected Exception: %s" % to_unicode(e), wrap_text=False)
  File "/Library/Python/2.7/site-packages/ansible/utils/display.py", line 261, in error
    self.display(new_msg, color=C.COLOR_ERROR, stderr=True)
  File "/Library/Python/2.7/site-packages/ansible/utils/display.py", line 124, in display
    msg2 = to_bytes(msg2, encoding=self._output_encoding(stderr=stderr))
 File "/Library/Python/2.7/site-packages/ansible/utils/unicode.py", line 208, in to_bytes

If you are like me you find yourself cloning a repo, making some proposed changes and then deciding to later contributing back using the GitHub Flow convention. Below is a set of instructions I've developed for myself on how to deal with this scenario and an explanation of why it matters based on jagregory's gist.

To follow GitHub flow you should really have created a fork initially as a public representation of the forked repository and the clone that instead. My understanding is that the typical setup would have your local repository pointing to your fork as origin and the original forked repository as upstream so that you can use these keywords in other git commands.

  1. Clone some repo (you've probably already done this step).

    git clone git@github...some-repo.git
@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